
<!DOCTYPE html>

<html>
  <head>
    <meta charset="utf-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>pymatgen.io.lobster.outputs &#8212; pymatgen 2020.7.3 documentation</title>
    <link rel="stylesheet" href="../../../../_static/basic.css" type="text/css" />
    <link rel="stylesheet" href="../../../../_static/pygments.css" type="text/css" />
    <script id="documentation_options" data-url_root="../../../../" src="../../../../_static/documentation_options.js"></script>
    <script src="../../../../_static/jquery.js"></script>
    <script src="../../../../_static/underscore.js"></script>
    <script src="../../../../_static/doctools.js"></script>
    <script src="../../../../_static/language_data.js"></script>
    <script async="async" src="https://cdnjs.cloudflare.com/ajax/libs/mathjax/2.7.7/latest.js?config=TeX-AMS-MML_HTMLorMML"></script>
    <link rel="index" title="Index" href="../../../../genindex.html" />
    <link rel="search" title="Search" href="../../../../search.html" />
 
<script type="text/javascript">
  var _gaq = _gaq || [];
  _gaq.push(['_setAccount', 'UA-33990148-1']);
  _gaq.push(['_trackPageview']);
</script>

  </head><body>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             accesskey="I">index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" accesskey="U">pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.lobster.outputs</a></li> 
      </ul>
    </div>  

    <div class="document">
      <div class="documentwrapper">
          <div class="body" role="main">
            
  <h1>Source code for pymatgen.io.lobster.outputs</h1><div class="highlight"><pre>
<span></span><span class="c1"># coding: utf-8</span>
<span class="c1"># Copyright (c) Pymatgen Development Team.</span>
<span class="c1"># Distributed under the terms of the MIT License</span>

<span class="sd">&quot;&quot;&quot;</span>
<span class="sd">Module for reading Lobster output files. For more information</span>
<span class="sd">on LOBSTER see www.cohp.de.</span>
<span class="sd">&quot;&quot;&quot;</span>

<span class="kn">import</span> <span class="nn">collections</span>
<span class="kn">import</span> <span class="nn">fnmatch</span>
<span class="kn">import</span> <span class="nn">os</span>
<span class="kn">import</span> <span class="nn">re</span>
<span class="kn">import</span> <span class="nn">warnings</span>
<span class="kn">from</span> <span class="nn">collections</span> <span class="kn">import</span> <span class="n">defaultdict</span>
<span class="kn">from</span> <span class="nn">typing</span> <span class="kn">import</span> <span class="n">Dict</span><span class="p">,</span> <span class="n">Any</span><span class="p">,</span> <span class="n">Optional</span><span class="p">,</span> <span class="n">List</span>

<span class="kn">import</span> <span class="nn">numpy</span> <span class="k">as</span> <span class="nn">np</span>
<span class="kn">from</span> <span class="nn">monty.io</span> <span class="kn">import</span> <span class="n">zopen</span>

<span class="kn">from</span> <span class="nn">pymatgen.core.structure</span> <span class="kn">import</span> <span class="n">Structure</span>
<span class="kn">from</span> <span class="nn">pymatgen.electronic_structure.bandstructure</span> <span class="kn">import</span> <span class="n">LobsterBandStructureSymmLine</span>
<span class="kn">from</span> <span class="nn">pymatgen.electronic_structure.core</span> <span class="kn">import</span> <span class="n">Spin</span><span class="p">,</span> <span class="n">Orbital</span>
<span class="kn">from</span> <span class="nn">pymatgen.electronic_structure.dos</span> <span class="kn">import</span> <span class="n">Dos</span><span class="p">,</span> <span class="n">LobsterCompleteDos</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.vasp.inputs</span> <span class="kn">import</span> <span class="n">Kpoints</span>
<span class="kn">from</span> <span class="nn">pymatgen.io.vasp.outputs</span> <span class="kn">import</span> <span class="n">Vasprun</span>

<span class="n">__author__</span> <span class="o">=</span> <span class="s2">&quot;Janine George, Marco Esters&quot;</span>
<span class="n">__copyright__</span> <span class="o">=</span> <span class="s2">&quot;Copyright 2017, The Materials Project&quot;</span>
<span class="n">__version__</span> <span class="o">=</span> <span class="s2">&quot;0.2&quot;</span>
<span class="n">__maintainer__</span> <span class="o">=</span> <span class="s2">&quot;Janine George, Marco Esters &quot;</span>
<span class="n">__email__</span> <span class="o">=</span> <span class="s2">&quot;janine.george@uclouvain.be, esters@uoregon.edu&quot;</span>
<span class="n">__date__</span> <span class="o">=</span> <span class="s2">&quot;Dec 13, 2017&quot;</span>

<span class="n">MODULE_DIR</span> <span class="o">=</span> <span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">dirname</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">abspath</span><span class="p">(</span><span class="vm">__file__</span><span class="p">))</span>


<div class="viewcode-block" id="Cohpcar"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Cohpcar">[docs]</a><span class="k">class</span> <span class="nc">Cohpcar</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class to read COHPCAR/COOPCAR files generated by LOBSTER.</span>

<span class="sd">    .. attribute: cohp_data</span>

<span class="sd">         Dict that contains the COHP data of the form:</span>
<span class="sd">           {bond: {&quot;COHP&quot;: {Spin.up: cohps, Spin.down:cohps},</span>
<span class="sd">                   &quot;ICOHP&quot;: {Spin.up: icohps, Spin.down: icohps},</span>
<span class="sd">                   &quot;length&quot;: bond length,</span>
<span class="sd">                   &quot;sites&quot;: sites corresponding to the bond}</span>
<span class="sd">         Also contains an entry for the average, which does not have</span>
<span class="sd">         a &quot;length&quot; key.</span>

<span class="sd">    .. attribute: efermi</span>

<span class="sd">         The Fermi energy in eV.</span>

<span class="sd">    .. attribute: energies</span>

<span class="sd">         Sequence of energies in eV. Note that LOBSTER shifts the energies</span>
<span class="sd">         so that the Fermi energy is at zero.</span>

<span class="sd">    .. attribute: is_spin_polarized</span>

<span class="sd">         Boolean to indicate if the calculation is spin polarized.</span>

<span class="sd">    .. attribute: orb_res_cohp</span>

<span class="sd">        orb_cohp[label] = {bond_data[&quot;orb_label&quot;]: {&quot;COHP&quot;: {Spin.up: cohps, Spin.down:cohps},</span>
<span class="sd">                                                     &quot;ICOHP&quot;: {Spin.up: icohps, Spin.down: icohps},</span>
<span class="sd">                                                     &quot;orbitals&quot;: orbitals,</span>
<span class="sd">                                                     &quot;length&quot;: bond lengths,</span>
<span class="sd">                                                     &quot;sites&quot;: sites corresponding to the bond}}</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">are_coops</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">filename</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            are_coops: Determines if the file is a list of COHPs or COOPs.</span>
<span class="sd">              Default is False for COHPs.</span>
<span class="sd">            filename: Name of the COHPCAR file. If it is None, the default</span>
<span class="sd">              file name will be chosen, depending on the value of are_coops.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">are_coops</span> <span class="o">=</span> <span class="n">are_coops</span>
        <span class="k">if</span> <span class="n">filename</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">filename</span> <span class="o">=</span> <span class="s2">&quot;COOPCAR.lobster&quot;</span> <span class="k">if</span> <span class="n">are_coops</span> \
                <span class="k">else</span> <span class="s2">&quot;COHPCAR.lobster&quot;</span>

        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s2">&quot;rt&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">contents</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

        <span class="c1"># The parameters line is the second line in a COHPCAR file. It</span>
        <span class="c1"># contains all parameters that are needed to map the file.</span>
        <span class="n">parameters</span> <span class="o">=</span> <span class="n">contents</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
        <span class="c1"># Subtract 1 to skip the average</span>
        <span class="n">num_bonds</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span> <span class="o">-</span> <span class="mi">1</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">efermi</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>
        <span class="k">if</span> <span class="nb">int</span><span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
            <span class="n">spins</span> <span class="o">=</span> <span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">,</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">is_spin_polarized</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">spins</span> <span class="o">=</span> <span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">is_spin_polarized</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="c1"># The COHP data start in row num_bonds + 3</span>
        <span class="n">data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">(),</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">float</span><span class="p">)</span> <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">contents</span><span class="p">[</span><span class="n">num_bonds</span> <span class="o">+</span> <span class="mi">3</span><span class="p">:]])</span><span class="o">.</span><span class="n">transpose</span><span class="p">()</span>
        <span class="n">data</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">(),</span> <span class="n">dtype</span><span class="o">=</span><span class="nb">float</span><span class="p">)</span> <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">contents</span><span class="p">[</span><span class="n">num_bonds</span> <span class="o">+</span> <span class="mi">3</span><span class="p">:]])</span><span class="o">.</span><span class="n">transpose</span><span class="p">()</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">energies</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
        <span class="n">cohp_data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;average&quot;</span><span class="p">:</span> <span class="p">{</span><span class="s2">&quot;COHP&quot;</span><span class="p">:</span> <span class="p">{</span><span class="n">spin</span><span class="p">:</span> <span class="n">data</span><span class="p">[</span><span class="mi">1</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">s</span> <span class="o">*</span> <span class="p">(</span><span class="n">num_bonds</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)]</span>
                                          <span class="k">for</span> <span class="n">s</span><span class="p">,</span> <span class="n">spin</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">spins</span><span class="p">)},</span>
                                 <span class="s2">&quot;ICOHP&quot;</span><span class="p">:</span> <span class="p">{</span><span class="n">spin</span><span class="p">:</span> <span class="n">data</span><span class="p">[</span><span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span> <span class="o">*</span> <span class="n">s</span> <span class="o">*</span> <span class="p">(</span><span class="n">num_bonds</span> <span class="o">+</span> <span class="mi">1</span><span class="p">)]</span>
                                           <span class="k">for</span> <span class="n">s</span><span class="p">,</span> <span class="n">spin</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">spins</span><span class="p">)}}}</span>  <span class="c1"># type: Dict[Any, Any]</span>

        <span class="n">orb_cohp</span> <span class="o">=</span> <span class="p">{}</span>  <span class="c1"># type: Dict[str, Any]</span>
        <span class="c1"># present for Lobster versions older than Lobster 2.2.0</span>
        <span class="n">veryold</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="c1"># the labeling had to be changed: there are more than one COHP for each atom combination</span>
        <span class="c1"># this is done to make the labeling consistent with ICOHPLIST.lobster</span>
        <span class="n">bondnumber</span> <span class="o">=</span> <span class="mi">0</span>
        <span class="k">for</span> <span class="n">bond</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">num_bonds</span><span class="p">):</span>
            <span class="n">bond_data</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_bond_data</span><span class="p">(</span><span class="n">contents</span><span class="p">[</span><span class="mi">3</span> <span class="o">+</span> <span class="n">bond</span><span class="p">])</span>

            <span class="n">label</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">bondnumber</span><span class="p">)</span>

            <span class="n">orbs</span> <span class="o">=</span> <span class="n">bond_data</span><span class="p">[</span><span class="s2">&quot;orbitals&quot;</span><span class="p">]</span>
            <span class="n">cohp</span> <span class="o">=</span> <span class="p">{</span><span class="n">spin</span><span class="p">:</span> <span class="n">data</span><span class="p">[</span><span class="mi">2</span> <span class="o">*</span> <span class="p">(</span><span class="n">bond</span> <span class="o">+</span> <span class="n">s</span> <span class="o">*</span> <span class="p">(</span><span class="n">num_bonds</span> <span class="o">+</span> <span class="mi">1</span><span class="p">))</span> <span class="o">+</span> <span class="mi">3</span><span class="p">]</span>
                    <span class="k">for</span> <span class="n">s</span><span class="p">,</span> <span class="n">spin</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">spins</span><span class="p">)}</span>

            <span class="n">icohp</span> <span class="o">=</span> <span class="p">{</span><span class="n">spin</span><span class="p">:</span> <span class="n">data</span><span class="p">[</span><span class="mi">2</span> <span class="o">*</span> <span class="p">(</span><span class="n">bond</span> <span class="o">+</span> <span class="n">s</span> <span class="o">*</span> <span class="p">(</span><span class="n">num_bonds</span> <span class="o">+</span> <span class="mi">1</span><span class="p">))</span> <span class="o">+</span> <span class="mi">4</span><span class="p">]</span>
                     <span class="k">for</span> <span class="n">s</span><span class="p">,</span> <span class="n">spin</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">spins</span><span class="p">)}</span>
            <span class="k">if</span> <span class="n">orbs</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">bondnumber</span> <span class="o">=</span> <span class="n">bondnumber</span> <span class="o">+</span> <span class="mi">1</span>
                <span class="n">label</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">bondnumber</span><span class="p">)</span>
                <span class="n">cohp_data</span><span class="p">[</span><span class="n">label</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;COHP&quot;</span><span class="p">:</span> <span class="n">cohp</span><span class="p">,</span> <span class="s2">&quot;ICOHP&quot;</span><span class="p">:</span> <span class="n">icohp</span><span class="p">,</span>
                                    <span class="s2">&quot;length&quot;</span><span class="p">:</span> <span class="n">bond_data</span><span class="p">[</span><span class="s2">&quot;length&quot;</span><span class="p">],</span>
                                    <span class="s2">&quot;sites&quot;</span><span class="p">:</span> <span class="n">bond_data</span><span class="p">[</span><span class="s2">&quot;sites&quot;</span><span class="p">]}</span>

            <span class="k">elif</span> <span class="n">label</span> <span class="ow">in</span> <span class="n">orb_cohp</span><span class="p">:</span>
                <span class="n">orb_cohp</span><span class="p">[</span><span class="n">label</span><span class="p">]</span><span class="o">.</span><span class="n">update</span><span class="p">(</span>
                    <span class="p">{</span><span class="n">bond_data</span><span class="p">[</span><span class="s2">&quot;orb_label&quot;</span><span class="p">]:</span> <span class="p">{</span><span class="s2">&quot;COHP&quot;</span><span class="p">:</span> <span class="n">cohp</span><span class="p">,</span> <span class="s2">&quot;ICOHP&quot;</span><span class="p">:</span> <span class="n">icohp</span><span class="p">,</span> <span class="s2">&quot;orbitals&quot;</span><span class="p">:</span> <span class="n">orbs</span><span class="p">,</span>
                                              <span class="s2">&quot;length&quot;</span><span class="p">:</span> <span class="n">bond_data</span><span class="p">[</span><span class="s2">&quot;length&quot;</span><span class="p">],</span> <span class="s2">&quot;sites&quot;</span><span class="p">:</span> <span class="n">bond_data</span><span class="p">[</span><span class="s2">&quot;sites&quot;</span><span class="p">]}})</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="c1"># present for Lobster versions older than Lobster 2.2.0</span>
                <span class="k">if</span> <span class="n">bondnumber</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="n">veryold</span> <span class="o">=</span> <span class="kc">True</span>
                <span class="k">if</span> <span class="n">veryold</span><span class="p">:</span>
                    <span class="n">bondnumber</span> <span class="o">+=</span> <span class="mi">1</span>
                    <span class="n">label</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">bondnumber</span><span class="p">)</span>

                <span class="n">orb_cohp</span><span class="p">[</span><span class="n">label</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="n">bond_data</span><span class="p">[</span><span class="s2">&quot;orb_label&quot;</span><span class="p">]:</span> <span class="p">{</span><span class="s2">&quot;COHP&quot;</span><span class="p">:</span> <span class="n">cohp</span><span class="p">,</span>
                                                            <span class="s2">&quot;ICOHP&quot;</span><span class="p">:</span> <span class="n">icohp</span><span class="p">,</span>
                                                            <span class="s2">&quot;orbitals&quot;</span><span class="p">:</span> <span class="n">orbs</span><span class="p">,</span>
                                                            <span class="s2">&quot;length&quot;</span><span class="p">:</span> <span class="n">bond_data</span><span class="p">[</span><span class="s2">&quot;length&quot;</span><span class="p">],</span>
                                                            <span class="s2">&quot;sites&quot;</span><span class="p">:</span> <span class="n">bond_data</span><span class="p">[</span><span class="s2">&quot;sites&quot;</span><span class="p">]}}</span>

        <span class="c1"># present for lobster older than 2.2.0</span>
        <span class="k">if</span> <span class="n">veryold</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">bond_str</span> <span class="ow">in</span> <span class="n">orb_cohp</span><span class="p">:</span>
                <span class="n">cohp_data</span><span class="p">[</span><span class="n">bond_str</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;COHP&quot;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span> <span class="s2">&quot;ICOHP&quot;</span><span class="p">:</span> <span class="kc">None</span><span class="p">,</span>
                                       <span class="s2">&quot;length&quot;</span><span class="p">:</span> <span class="n">bond_data</span><span class="p">[</span><span class="s2">&quot;length&quot;</span><span class="p">],</span>
                                       <span class="s2">&quot;sites&quot;</span><span class="p">:</span> <span class="n">bond_data</span><span class="p">[</span><span class="s2">&quot;sites&quot;</span><span class="p">]}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">orb_res_cohp</span> <span class="o">=</span> <span class="n">orb_cohp</span> <span class="k">if</span> <span class="n">orb_cohp</span> <span class="k">else</span> <span class="kc">None</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">cohp_data</span> <span class="o">=</span> <span class="n">cohp_data</span>

    <span class="nd">@staticmethod</span>
    <span class="k">def</span> <span class="nf">_get_bond_data</span><span class="p">(</span><span class="n">line</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">dict</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Subroutine to extract bond label, site indices, and length from</span>
<span class="sd">        a LOBSTER header line. The site indices are zero-based, so they</span>
<span class="sd">        can be easily used with a Structure object.</span>

<span class="sd">        Example header line: No.4:Fe1-&gt;Fe9(2.4524893531900283)</span>
<span class="sd">        Example header line for orbtial-resolved COHP:</span>
<span class="sd">            No.1:Fe1[3p_x]-&gt;Fe2[3d_x^2-y^2](2.456180552772262)</span>

<span class="sd">        Args:</span>
<span class="sd">            line: line in the COHPCAR header describing the bond.</span>

<span class="sd">        Returns:</span>
<span class="sd">            Dict with the bond label, the bond length, a tuple of the site</span>
<span class="sd">            indices, a tuple containing the orbitals (if orbital-resolved),</span>
<span class="sd">            and a label for the orbitals (if orbital-resolved).</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">orb_labs</span> <span class="o">=</span> <span class="p">[</span><span class="s2">&quot;s&quot;</span><span class="p">,</span> <span class="s2">&quot;p_y&quot;</span><span class="p">,</span> <span class="s2">&quot;p_z&quot;</span><span class="p">,</span> <span class="s2">&quot;p_x&quot;</span><span class="p">,</span> <span class="s2">&quot;d_xy&quot;</span><span class="p">,</span> <span class="s2">&quot;d_yz&quot;</span><span class="p">,</span> <span class="s2">&quot;d_z^2&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;d_xz&quot;</span><span class="p">,</span> <span class="s2">&quot;d_x^2-y^2&quot;</span><span class="p">,</span> <span class="s2">&quot;f_y(3x^2-y^2)&quot;</span><span class="p">,</span> <span class="s2">&quot;f_xyz&quot;</span><span class="p">,</span>
                    <span class="s2">&quot;f_yz^2&quot;</span><span class="p">,</span> <span class="s2">&quot;f_z^3&quot;</span><span class="p">,</span> <span class="s2">&quot;f_xz^2&quot;</span><span class="p">,</span> <span class="s2">&quot;f_z(x^2-y^2)&quot;</span><span class="p">,</span> <span class="s2">&quot;f_x(x^2-3y^2)&quot;</span><span class="p">]</span>

        <span class="n">line_new</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">rsplit</span><span class="p">(</span><span class="s2">&quot;(&quot;</span><span class="p">,</span> <span class="mi">1</span><span class="p">)</span>
        <span class="c1"># bondnumber = line[0].replace(&quot;-&gt;&quot;, &quot;:&quot;).replace(&quot;.&quot;, &quot;:&quot;).split(&#39;:&#39;)[1]</span>
        <span class="n">length</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">line_new</span><span class="p">[</span><span class="o">-</span><span class="mi">1</span><span class="p">][:</span><span class="o">-</span><span class="mi">1</span><span class="p">])</span>

        <span class="n">sites</span> <span class="o">=</span> <span class="n">line_new</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s2">&quot;-&gt;&quot;</span><span class="p">,</span> <span class="s2">&quot;:&quot;</span><span class="p">)</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;:&quot;</span><span class="p">)[</span><span class="mi">1</span><span class="p">:</span><span class="mi">3</span><span class="p">]</span>
        <span class="n">site_indices</span> <span class="o">=</span> <span class="nb">tuple</span><span class="p">(</span><span class="nb">int</span><span class="p">(</span><span class="n">re</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;\D+&quot;</span><span class="p">,</span> <span class="n">site</span><span class="p">)[</span><span class="mi">1</span><span class="p">])</span> <span class="o">-</span> <span class="mi">1</span>
                             <span class="k">for</span> <span class="n">site</span> <span class="ow">in</span> <span class="n">sites</span><span class="p">)</span>

        <span class="c1"># species = tuple(re.split(r&quot;\d+&quot;, site)[0] for site in sites)</span>
        <span class="k">if</span> <span class="s2">&quot;[&quot;</span> <span class="ow">in</span> <span class="n">sites</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
            <span class="n">orbs</span> <span class="o">=</span> <span class="p">[</span><span class="n">re</span><span class="o">.</span><span class="n">findall</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;\[(.*)\]&quot;</span><span class="p">,</span> <span class="n">site</span><span class="p">)[</span><span class="mi">0</span><span class="p">]</span> <span class="k">for</span> <span class="n">site</span> <span class="ow">in</span> <span class="n">sites</span><span class="p">]</span>
            <span class="n">orbitals</span> <span class="o">=</span> <span class="p">[</span><span class="nb">tuple</span><span class="p">((</span><span class="nb">int</span><span class="p">(</span><span class="n">orb</span><span class="p">[</span><span class="mi">0</span><span class="p">]),</span> <span class="n">Orbital</span><span class="p">(</span><span class="n">orb_labs</span><span class="o">.</span><span class="n">index</span><span class="p">(</span><span class="n">orb</span><span class="p">[</span><span class="mi">1</span><span class="p">:]))))</span> <span class="k">for</span> <span class="n">orb</span> <span class="ow">in</span>
                        <span class="n">orbs</span><span class="p">]</span>  <span class="c1"># type: Any</span>
            <span class="n">orb_label</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">%d%s</span><span class="s2">-</span><span class="si">%d%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">orbitals</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="n">orbitals</span><span class="p">[</span><span class="mi">0</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="p">,</span>
                                       <span class="n">orbitals</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">0</span><span class="p">],</span> <span class="n">orbitals</span><span class="p">[</span><span class="mi">1</span><span class="p">][</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">name</span><span class="p">)</span>  <span class="c1"># type: Any</span>

        <span class="k">else</span><span class="p">:</span>
            <span class="n">orbitals</span> <span class="o">=</span> <span class="kc">None</span>
            <span class="n">orb_label</span> <span class="o">=</span> <span class="kc">None</span>

        <span class="c1"># a label based on the species alone is not feasible, there can be more than one bond for each atom combination</span>
        <span class="c1"># label = &quot;%s&quot; % (bondnumber)</span>

        <span class="n">bond_data</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;length&quot;</span><span class="p">:</span> <span class="n">length</span><span class="p">,</span> <span class="s2">&quot;sites&quot;</span><span class="p">:</span> <span class="n">site_indices</span><span class="p">,</span>
                     <span class="s2">&quot;orbitals&quot;</span><span class="p">:</span> <span class="n">orbitals</span><span class="p">,</span> <span class="s2">&quot;orb_label&quot;</span><span class="p">:</span> <span class="n">orb_label</span><span class="p">}</span>
        <span class="k">return</span> <span class="n">bond_data</span></div>


<div class="viewcode-block" id="Icohplist"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Icohplist">[docs]</a><span class="k">class</span> <span class="nc">Icohplist</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class to read ICOHPLIST/ICOOPLIST files generated by LOBSTER.</span>

<span class="sd">    .. attribute: are_coops</span>
<span class="sd">         Boolean to indicate if the populations are COOPs or COHPs.</span>

<span class="sd">    .. attribute: is_spin_polarized</span>
<span class="sd">         Boolean to indicate if the calculation is spin polarized.</span>

<span class="sd">    .. attribute: Icohplist</span>
<span class="sd">        Dict containing the listfile data of the form:</span>
<span class="sd">           {bond: &quot;length&quot;: bond length,</span>
<span class="sd">                  &quot;number_of_bonds&quot;: number of bonds</span>
<span class="sd">                  &quot;icohp&quot;: {Spin.up: ICOHP(Ef) spin up, Spin.down: ...}}</span>

<span class="sd">    .. attribute: IcohpCollection</span>
<span class="sd">        IcohpCollection Object</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">are_coops</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">filename</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="kc">None</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            are_coops: Determines if the file is a list of ICOHPs or ICOOPs.</span>
<span class="sd">              Defaults to False for ICOHPs.</span>
<span class="sd">            filename: Name of the ICOHPLIST file. If it is None, the default</span>
<span class="sd">              file name will be chosen, depending on the value of are_coops.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">are_coops</span> <span class="o">=</span> <span class="n">are_coops</span>
        <span class="k">if</span> <span class="n">filename</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">filename</span> <span class="o">=</span> <span class="s2">&quot;ICOOPLIST.lobster&quot;</span> <span class="k">if</span> <span class="n">are_coops</span> \
                <span class="k">else</span> <span class="s2">&quot;ICOHPLIST.lobster&quot;</span>

        <span class="c1"># LOBSTER list files have an extra trailing blank line</span>
        <span class="c1"># and we don&#39;t need the header.</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s2">&quot;ICOHPLIST file contains no data.&quot;</span><span class="p">)</span>

        <span class="c1"># Which Lobster version?</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">())</span> <span class="o">==</span> <span class="mi">8</span><span class="p">:</span>
            <span class="n">version</span> <span class="o">=</span> <span class="s1">&#39;3.1.1&#39;</span>
        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">())</span> <span class="o">==</span> <span class="mi">6</span><span class="p">:</span>
            <span class="n">version</span> <span class="o">=</span> <span class="s1">&#39;2.2.1&#39;</span>
            <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s1">&#39;Please consider using the new Lobster version. See www.cohp.de.&#39;</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span>

        <span class="c1"># If the calculation is spin polarized, the line in the middle</span>
        <span class="c1"># of the file will be another header line.</span>
        <span class="k">if</span> <span class="s2">&quot;distance&quot;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">[</span><span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">//</span> <span class="mi">2</span><span class="p">]:</span>
            <span class="n">num_bonds</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">//</span> <span class="mi">2</span>
            <span class="k">if</span> <span class="n">num_bonds</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s2">&quot;ICOHPLIST file contains no data.&quot;</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">is_spin_polarized</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">num_bonds</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">is_spin_polarized</span> <span class="o">=</span> <span class="kc">False</span>

        <span class="n">list_labels</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">list_atom1</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">list_atom2</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">list_length</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">list_translation</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">list_num</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">list_icohp</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">bond</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">num_bonds</span><span class="p">):</span>
            <span class="n">line</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">bond</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="n">icohp</span> <span class="o">=</span> <span class="p">{}</span>
            <span class="k">if</span> <span class="n">version</span> <span class="o">==</span> <span class="s1">&#39;2.2.1&#39;</span><span class="p">:</span>
                <span class="n">label</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">atom1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
                <span class="n">atom2</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
                <span class="n">length</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">3</span><span class="p">])</span>
                <span class="n">icohp</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">4</span><span class="p">])</span>
                <span class="n">num</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">5</span><span class="p">])</span>
                <span class="n">translation</span> <span class="o">=</span> <span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">0</span><span class="p">]</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                    <span class="n">icohp</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">bond</span> <span class="o">+</span> <span class="n">num_bonds</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">4</span><span class="p">])</span>

            <span class="k">elif</span> <span class="n">version</span> <span class="o">==</span> <span class="s1">&#39;3.1.1&#39;</span><span class="p">:</span>
                <span class="n">label</span> <span class="o">=</span> <span class="s2">&quot;</span><span class="si">%s</span><span class="s2">&quot;</span> <span class="o">%</span> <span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                <span class="n">atom1</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
                <span class="n">atom2</span> <span class="o">=</span> <span class="nb">str</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
                <span class="n">length</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">3</span><span class="p">])</span>
                <span class="n">translation</span> <span class="o">=</span> <span class="p">[</span><span class="nb">int</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">4</span><span class="p">]),</span> <span class="nb">int</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">5</span><span class="p">]),</span> <span class="nb">int</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">6</span><span class="p">])]</span>
                <span class="n">icohp</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">7</span><span class="p">])</span>
                <span class="n">num</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="mi">1</span><span class="p">)</span>

                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">:</span>
                    <span class="n">icohp</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">data</span><span class="p">[</span><span class="n">bond</span> <span class="o">+</span> <span class="n">num_bonds</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">7</span><span class="p">])</span>

            <span class="n">list_labels</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">label</span><span class="p">)</span>
            <span class="n">list_atom1</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">atom1</span><span class="p">)</span>
            <span class="n">list_atom2</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">atom2</span><span class="p">)</span>
            <span class="n">list_length</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">length</span><span class="p">)</span>
            <span class="n">list_translation</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">translation</span><span class="p">)</span>
            <span class="n">list_num</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">num</span><span class="p">)</span>
            <span class="n">list_icohp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">icohp</span><span class="p">)</span>

        <span class="c1"># to avoid circular dependencies</span>
        <span class="kn">from</span> <span class="nn">pymatgen.electronic_structure.cohp</span> <span class="kn">import</span> <span class="n">IcohpCollection</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_icohpcollection</span> <span class="o">=</span> <span class="n">IcohpCollection</span><span class="p">(</span><span class="n">are_coops</span><span class="o">=</span><span class="n">are_coops</span><span class="p">,</span> <span class="n">list_labels</span><span class="o">=</span><span class="n">list_labels</span><span class="p">,</span> <span class="n">list_atom1</span><span class="o">=</span><span class="n">list_atom1</span><span class="p">,</span>
                                                <span class="n">list_atom2</span><span class="o">=</span><span class="n">list_atom2</span><span class="p">,</span> <span class="n">list_length</span><span class="o">=</span><span class="n">list_length</span><span class="p">,</span>
                                                <span class="n">list_translation</span><span class="o">=</span><span class="n">list_translation</span><span class="p">,</span> <span class="n">list_num</span><span class="o">=</span><span class="n">list_num</span><span class="p">,</span>
                                                <span class="n">list_icohp</span><span class="o">=</span><span class="n">list_icohp</span><span class="p">,</span> <span class="n">is_spin_polarized</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">is_spin_polarized</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">icohplist</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Dict</span><span class="p">[</span><span class="n">Any</span><span class="p">,</span> <span class="n">Dict</span><span class="p">[</span><span class="nb">str</span><span class="p">,</span> <span class="n">Any</span><span class="p">]]:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns: icohplist compatible with older version of this class</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">icohplist_new</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">value</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">_icohpcollection</span><span class="o">.</span><span class="n">_icohplist</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="n">icohplist_new</span><span class="p">[</span><span class="n">key</span><span class="p">]</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;length&quot;</span><span class="p">:</span> <span class="n">value</span><span class="o">.</span><span class="n">_length</span><span class="p">,</span> <span class="s2">&quot;number_of_bonds&quot;</span><span class="p">:</span> <span class="n">value</span><span class="o">.</span><span class="n">_num</span><span class="p">,</span>
                                  <span class="s2">&quot;icohp&quot;</span><span class="p">:</span> <span class="n">value</span><span class="o">.</span><span class="n">_icohp</span><span class="p">,</span> <span class="s2">&quot;translation&quot;</span><span class="p">:</span> <span class="n">value</span><span class="o">.</span><span class="n">_translation</span><span class="p">}</span>
        <span class="k">return</span> <span class="n">icohplist_new</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">icohpcollection</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Returns: IcohpCollection object</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_icohpcollection</span></div>


<div class="viewcode-block" id="Doscar"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Doscar">[docs]</a><span class="k">class</span> <span class="nc">Doscar</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class to deal with Lobster&#39;s projected DOS and local projected DOS.</span>
<span class="sd">    The beforehand quantum-chemical calculation was performed with VASP</span>

<span class="sd">    .. attribute:: completedos</span>

<span class="sd">        LobsterCompleteDos Object</span>

<span class="sd">    .. attribute:: pdos</span>
<span class="sd">        List of Dict including numpy arrays with pdos. Access as pdos[atomindex][&#39;orbitalstring&#39;][&#39;Spin.up/Spin.down&#39;]</span>

<span class="sd">    .. attribute:: tdos</span>
<span class="sd">        Dos Object of the total density of states</span>

<span class="sd">    .. attribute:: energies</span>
<span class="sd">        numpy array of the energies at which the DOS was calculated (in eV, relative to Efermi)</span>

<span class="sd">    .. attribute:: tdensities</span>
<span class="sd">        tdensities[Spin.up]: numpy array of the total density of states for the Spin.up contribution at each of the</span>
<span class="sd">            energies</span>
<span class="sd">        tdensities[Spin.down]: numpy array of the total density of states for the Spin.down contribution at each of the</span>
<span class="sd">            energies</span>

<span class="sd">        if is_spin_polarized=False:</span>
<span class="sd">        tdensities[Spin.up]: numpy array of the total density of states</span>


<span class="sd">    .. attribute:: itdensities:</span>
<span class="sd">        itdensities[Spin.up]: numpy array of the total density of states for the Spin.up contribution at each of the</span>
<span class="sd">            energies</span>
<span class="sd">        itdensities[Spin.down]: numpy array of the total density of states for the Spin.down contribution at each of the</span>
<span class="sd">            energies</span>

<span class="sd">        if is_spin_polarized=False:</span>
<span class="sd">        itdensities[Spin.up]: numpy array of the total density of states</span>


<span class="sd">    .. attribute:: is_spin_polarized</span>
<span class="sd">        Boolean. Tells if the system is spin polarized</span>


<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">doscar</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;DOSCAR.lobster&quot;</span><span class="p">,</span> <span class="n">structure_file</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;POSCAR&quot;</span><span class="p">,</span> <span class="n">dftprogram</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;Vasp&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            doscar: DOSCAR filename, typically &quot;DOSCAR.lobster&quot;</span>
<span class="sd">            structure_file: for vasp, this is typically &quot;POSCAR&quot;</span>
<span class="sd">            dftprogram: so far only &quot;vasp&quot; is implemented</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_doscar</span> <span class="o">=</span> <span class="n">doscar</span>
        <span class="k">if</span> <span class="n">dftprogram</span> <span class="o">==</span> <span class="s2">&quot;Vasp&quot;</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_final_structure</span> <span class="o">=</span> <span class="n">Structure</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">structure_file</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_parse_doscar</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">_parse_doscar</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="n">doscar</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_doscar</span>

        <span class="n">tdensities</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">itdensities</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">f</span> <span class="o">=</span> <span class="nb">open</span><span class="p">(</span><span class="n">doscar</span><span class="p">)</span>
        <span class="n">natoms</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">0</span><span class="p">])</span>
        <span class="n">efermi</span> <span class="o">=</span> <span class="nb">float</span><span class="p">([</span><span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span> <span class="k">for</span> <span class="n">nn</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">4</span><span class="p">)][</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">17</span><span class="p">])</span>
        <span class="n">dos</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">orbitals</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">atom</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">natoms</span> <span class="o">+</span> <span class="mi">1</span><span class="p">):</span>
            <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span>
            <span class="n">ndos</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">2</span><span class="p">])</span>
            <span class="n">orbitals</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;;&#39;</span><span class="p">)[</span><span class="o">-</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">())</span>
            <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="n">cdos</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">zeros</span><span class="p">((</span><span class="n">ndos</span><span class="p">,</span> <span class="nb">len</span><span class="p">(</span><span class="n">line</span><span class="p">)))</span>
            <span class="n">cdos</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
            <span class="k">for</span> <span class="n">nd</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">ndos</span><span class="p">):</span>
                <span class="n">line</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">readline</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                <span class="n">cdos</span><span class="p">[</span><span class="n">nd</span><span class="p">]</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">line</span><span class="p">)</span>
            <span class="n">dos</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">cdos</span><span class="p">)</span>
        <span class="n">f</span><span class="o">.</span><span class="n">close</span><span class="p">()</span>
        <span class="n">doshere</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">(</span><span class="n">dos</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">doshere</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="p">:])</span> <span class="o">==</span> <span class="mi">5</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_is_spin_polarized</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">doshere</span><span class="p">[</span><span class="mi">0</span><span class="p">,</span> <span class="p">:])</span> <span class="o">==</span> <span class="mi">3</span><span class="p">:</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">_is_spin_polarized</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;There is something wrong with the DOSCAR. Can&#39;t extract spin polarization.&quot;</span><span class="p">)</span>
        <span class="n">energies</span> <span class="o">=</span> <span class="n">doshere</span><span class="p">[:,</span> <span class="mi">0</span><span class="p">]</span>
        <span class="k">if</span> <span class="ow">not</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_spin_polarized</span><span class="p">:</span>
            <span class="n">tdensities</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span> <span class="o">=</span> <span class="n">doshere</span><span class="p">[:,</span> <span class="mi">1</span><span class="p">]</span>
            <span class="n">itdensities</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span> <span class="o">=</span> <span class="n">doshere</span><span class="p">[:,</span> <span class="mi">2</span><span class="p">]</span>
            <span class="n">pdoss</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">spin</span> <span class="o">=</span> <span class="n">Spin</span><span class="o">.</span><span class="n">up</span>
            <span class="k">for</span> <span class="n">atom</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">natoms</span><span class="p">):</span>
                <span class="n">pdos</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">dict</span><span class="p">)</span>
                <span class="n">data</span> <span class="o">=</span> <span class="n">dos</span><span class="p">[</span><span class="n">atom</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span>
                <span class="n">_</span><span class="p">,</span> <span class="n">ncol</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">shape</span>
                <span class="n">orbnumber</span> <span class="o">=</span> <span class="mi">0</span>
                <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">ncol</span><span class="p">):</span>
                    <span class="n">orb</span> <span class="o">=</span> <span class="n">orbitals</span><span class="p">[</span><span class="n">atom</span> <span class="o">+</span> <span class="mi">1</span><span class="p">][</span><span class="n">orbnumber</span><span class="p">]</span>
                    <span class="n">pdos</span><span class="p">[</span><span class="n">orb</span><span class="p">][</span><span class="n">spin</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[:,</span> <span class="n">j</span><span class="p">]</span>
                    <span class="n">orbnumber</span> <span class="o">=</span> <span class="n">orbnumber</span> <span class="o">+</span> <span class="mi">1</span>
                <span class="n">pdoss</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pdos</span><span class="p">)</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="n">tdensities</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span> <span class="o">=</span> <span class="n">doshere</span><span class="p">[:,</span> <span class="mi">1</span><span class="p">]</span>
            <span class="n">tdensities</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]</span> <span class="o">=</span> <span class="n">doshere</span><span class="p">[:,</span> <span class="mi">2</span><span class="p">]</span>
            <span class="n">itdensities</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span> <span class="o">=</span> <span class="n">doshere</span><span class="p">[:,</span> <span class="mi">3</span><span class="p">]</span>
            <span class="n">itdensities</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]</span> <span class="o">=</span> <span class="n">doshere</span><span class="p">[:,</span> <span class="mi">4</span><span class="p">]</span>
            <span class="n">pdoss</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">atom</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="n">natoms</span><span class="p">):</span>
                <span class="n">pdos</span> <span class="o">=</span> <span class="n">defaultdict</span><span class="p">(</span><span class="nb">dict</span><span class="p">)</span>
                <span class="n">data</span> <span class="o">=</span> <span class="n">dos</span><span class="p">[</span><span class="n">atom</span> <span class="o">+</span> <span class="mi">1</span><span class="p">]</span>
                <span class="n">_</span><span class="p">,</span> <span class="n">ncol</span> <span class="o">=</span> <span class="n">data</span><span class="o">.</span><span class="n">shape</span>
                <span class="n">orbnumber</span> <span class="o">=</span> <span class="mi">0</span>
                <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">1</span><span class="p">,</span> <span class="n">ncol</span><span class="p">):</span>
                    <span class="k">if</span> <span class="n">j</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                        <span class="n">spin</span> <span class="o">=</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="n">spin</span> <span class="o">=</span> <span class="n">Spin</span><span class="o">.</span><span class="n">up</span>
                    <span class="n">orb</span> <span class="o">=</span> <span class="n">orbitals</span><span class="p">[</span><span class="n">atom</span> <span class="o">+</span> <span class="mi">1</span><span class="p">][</span><span class="n">orbnumber</span><span class="p">]</span>
                    <span class="n">pdos</span><span class="p">[</span><span class="n">orb</span><span class="p">][</span><span class="n">spin</span><span class="p">]</span> <span class="o">=</span> <span class="n">data</span><span class="p">[:,</span> <span class="n">j</span><span class="p">]</span>
                    <span class="k">if</span> <span class="n">j</span> <span class="o">%</span> <span class="mi">2</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                        <span class="n">orbnumber</span> <span class="o">=</span> <span class="n">orbnumber</span> <span class="o">+</span> <span class="mi">1</span>
                <span class="n">pdoss</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">pdos</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_efermi</span> <span class="o">=</span> <span class="n">efermi</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_pdos</span> <span class="o">=</span> <span class="n">pdoss</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_tdos</span> <span class="o">=</span> <span class="n">Dos</span><span class="p">(</span><span class="n">efermi</span><span class="p">,</span> <span class="n">energies</span><span class="p">,</span> <span class="n">tdensities</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_energies</span> <span class="o">=</span> <span class="n">energies</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_tdensities</span> <span class="o">=</span> <span class="n">tdensities</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">_itdensities</span> <span class="o">=</span> <span class="n">itdensities</span>
        <span class="n">final_struct</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_final_structure</span>

        <span class="n">pdossneu</span> <span class="o">=</span> <span class="p">{</span><span class="n">final_struct</span><span class="p">[</span><span class="n">i</span><span class="p">]:</span> <span class="n">pdos</span> <span class="k">for</span> <span class="n">i</span><span class="p">,</span> <span class="n">pdos</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_pdos</span><span class="p">)}</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_completedos</span> <span class="o">=</span> <span class="n">LobsterCompleteDos</span><span class="p">(</span><span class="n">final_struct</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tdos</span><span class="p">,</span> <span class="n">pdossneu</span><span class="p">)</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">completedos</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">LobsterCompleteDos</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: CompleteDos</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_completedos</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">pdos</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">list</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Projected DOS</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_pdos</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">tdos</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Dos</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Total DOS</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tdos</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">energies</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Energies</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_energies</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">tdensities</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: total densities as a np.array</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_tdensities</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">itdensities</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: integrated total densities as a np.array</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_itdensities</span>

    <span class="nd">@property</span>
    <span class="k">def</span> <span class="nf">is_spin_polarized</span><span class="p">(</span><span class="bp">self</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        :return: Whether run is spin polarized.</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">return</span> <span class="bp">self</span><span class="o">.</span><span class="n">_is_spin_polarized</span></div>


<div class="viewcode-block" id="Charge"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Charge">[docs]</a><span class="k">class</span> <span class="nc">Charge</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class to read CHARGE files generated by LOBSTER</span>

<span class="sd">    .. attribute: atomlist</span>
<span class="sd">        List of atoms in CHARGE.lobster</span>
<span class="sd">    .. attribute: types</span>
<span class="sd">        List of types of atoms in CHARGE.lobster</span>
<span class="sd">    .. attribute: Mulliken</span>
<span class="sd">        List of Mulliken charges of atoms in CHARGE.lobster</span>
<span class="sd">    .. attribute: Loewdin</span>
<span class="sd">        List of Loewdin charges of atoms in CHARGE.Loewdin</span>
<span class="sd">    .. attribute: num_atoms</span>
<span class="sd">        Number of atoms in CHARGE.lobster</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;CHARGE.lobster&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            filename: filename for the CHARGE file, typically &quot;CHARGE.lobster&quot;</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)[</span><span class="mi">3</span><span class="p">:</span><span class="o">-</span><span class="mi">3</span><span class="p">]</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s2">&quot;CHARGES file contains no data.&quot;</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">num_atoms</span> <span class="o">=</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">atomlist</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># type: List[str]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">types</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># type: List[str]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Mulliken</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># type: List[float]</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">Loewdin</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># type: List[float]</span>
        <span class="k">for</span> <span class="n">atom</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="mi">0</span><span class="p">,</span> <span class="bp">self</span><span class="o">.</span><span class="n">num_atoms</span><span class="p">):</span>
            <span class="n">line</span> <span class="o">=</span> <span class="n">data</span><span class="p">[</span><span class="n">atom</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">atomlist</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">+</span> <span class="n">line</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">types</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">Mulliken</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">2</span><span class="p">]))</span>
            <span class="bp">self</span><span class="o">.</span><span class="n">Loewdin</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="p">[</span><span class="mi">3</span><span class="p">]))</span>

<div class="viewcode-block" id="Charge.get_structure_with_charges"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Charge.get_structure_with_charges">[docs]</a>    <span class="k">def</span> <span class="nf">get_structure_with_charges</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure_filename</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        get a Structure with Mulliken and Loewdin charges as site properties</span>
<span class="sd">        Args:</span>
<span class="sd">            structure_filename: filename of POSCAR</span>
<span class="sd">        Returns:</span>
<span class="sd">            Structure Object with Mulliken and Loewdin charges as site properties</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">struct</span> <span class="o">=</span> <span class="n">Structure</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">structure_filename</span><span class="p">)</span>
        <span class="n">Mulliken</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Mulliken</span>
        <span class="n">Loewdin</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">Loewdin</span>
        <span class="n">site_properties</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;Mulliken Charges&quot;</span><span class="p">:</span> <span class="n">Mulliken</span><span class="p">,</span> <span class="s2">&quot;Loewdin Charges&quot;</span><span class="p">:</span> <span class="n">Loewdin</span><span class="p">}</span>
        <span class="n">new_struct</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">site_properties</span><span class="o">=</span><span class="n">site_properties</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">new_struct</span></div></div>


<div class="viewcode-block" id="Lobsterout"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Lobsterout">[docs]</a><span class="k">class</span> <span class="nc">Lobsterout</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class to read in the lobsterout and evaluate the spilling, save the basis, save warnings, save infos</span>

<span class="sd">      .. attribute: basis_functions</span>
<span class="sd">        list of basis functions that were used in lobster run as strings</span>

<span class="sd">      .. attribute: basis_type</span>
<span class="sd">         list of basis type that were used in lobster run as strings</span>

<span class="sd">      .. attribute: chargespilling</span>
<span class="sd">         list of charge spilling (first entry: result for spin 1, second entry: result for spin 2 or not present)</span>

<span class="sd">      .. attribute: dftprogram</span>
<span class="sd">         string representing the dft program used for the calculation of the wave function</span>

<span class="sd">      .. attribute: elements</span>
<span class="sd">         list of strings of elements that were present in lobster calculation</span>

<span class="sd">      .. attribute: has_CHARGE</span>
<span class="sd">         Boolean, indicates that CHARGE.lobster is present</span>

<span class="sd">      .. attribute: has_COHPCAR</span>
<span class="sd">        Boolean, indicates that COHPCAR.lobster and ICOHPLIST.lobster are present</span>

<span class="sd">      .. attribute: has_COOPCAR</span>
<span class="sd">        Boolean, indicates that COOPCAR.lobster and ICOOPLIST.lobster are present</span>

<span class="sd">      .. attribute: has_DOSCAR</span>
<span class="sd">        Boolean, indicates that DOSCAR.lobster is present</span>

<span class="sd">      .. attribute: has_Projection</span>
<span class="sd">        Boolean, indcates that projectionData.lobster is present</span>

<span class="sd">      .. attribute: has_bandoverlaps</span>
<span class="sd">        Boolean, indcates that bandOverlaps.lobster is present</span>

<span class="sd">      .. attribute: has_density_of_energies</span>
<span class="sd">        Boolean, indicates that DensityOfEnergy.lobster is present</span>

<span class="sd">      .. attribute: has_fatbands</span>
<span class="sd">        Boolean, indicates that fatband calculation was performed</span>

<span class="sd">      .. attribute: has_grosspopulation</span>
<span class="sd">        Boolean, indicates that GROSSPOP.lobster is present</span>

<span class="sd">      .. attribute: info_lines</span>
<span class="sd">        string with additional infos on the run</span>

<span class="sd">      .. attribute: info_orthonormalization</span>
<span class="sd">        string with infos on orthonormalization</span>

<span class="sd">      .. attribute: is_restart_from_projection</span>
<span class="sd">        Boolean that indicates that calculation was restartet from existing projection file</span>

<span class="sd">      .. attribute: lobster_version</span>
<span class="sd">        string that indicates Lobster version</span>

<span class="sd">      .. attribute: number_of_spins</span>
<span class="sd">        Integer indicating the number of spins</span>

<span class="sd">      .. attribute: number_of_threads</span>
<span class="sd">       integer that indicates how many threads were used</span>

<span class="sd">      .. attribute: timing</span>
<span class="sd">        dict with infos on timing</span>

<span class="sd">      .. attribute: totalspilling</span>
<span class="sd">        list of values indicating the total spilling for spin channel 1 (and spin channel 2)</span>

<span class="sd">      .. attribute: warninglines</span>
<span class="sd">        string with all warnings</span>


<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="o">=</span><span class="s2">&quot;lobsterout&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            filename: filename of lobsterout</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s2">&quot;Make sure the lobsterout is read in correctly. This is a brand new class.&quot;</span><span class="p">)</span>
        <span class="c1"># read in file</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s1">&#39;rt&#39;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">data</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>  <span class="c1"># [3:-3]</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">data</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">IOError</span><span class="p">(</span><span class="s2">&quot;lobsterout does not contain any data&quot;</span><span class="p">)</span>

        <span class="c1"># check if Lobster starts from a projection</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">is_restart_from_projection</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_starts_from_projection</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">lobster_version</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_lobster_version</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">number_of_threads</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">_get_threads</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">))</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">dftprogram</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_dft_program</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">number_of_spins</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_number_of_spins</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="n">chargespilling</span><span class="p">,</span> <span class="n">totalspilling</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_spillings</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">,</span> <span class="n">number_of_spins</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">number_of_spins</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">chargespilling</span> <span class="o">=</span> <span class="n">chargespilling</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">totalspilling</span> <span class="o">=</span> <span class="n">totalspilling</span>

        <span class="n">elements</span><span class="p">,</span> <span class="n">basistype</span><span class="p">,</span> <span class="n">basisfunctions</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_elements_basistype_basisfunctions</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">elements</span> <span class="o">=</span> <span class="n">elements</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">basis_type</span> <span class="o">=</span> <span class="n">basistype</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">basis_functions</span> <span class="o">=</span> <span class="n">basisfunctions</span>

        <span class="n">wall_time</span><span class="p">,</span> <span class="n">user_time</span><span class="p">,</span> <span class="n">sys_time</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_timing</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="n">timing</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="n">timing</span><span class="p">[</span><span class="s1">&#39;walltime&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">wall_time</span>
        <span class="n">timing</span><span class="p">[</span><span class="s1">&#39;usertime&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">user_time</span>
        <span class="n">timing</span><span class="p">[</span><span class="s1">&#39;sys_time&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="n">sys_time</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">timing</span> <span class="o">=</span> <span class="n">timing</span>

        <span class="n">warninglines</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_warning_lines</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">warninglines</span> <span class="o">=</span> <span class="n">warninglines</span>

        <span class="n">orthowarning</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_warning_orthonormalization</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">info_orthonormalization</span> <span class="o">=</span> <span class="n">orthowarning</span>

        <span class="n">infos</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_get_all_info_lines</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">info_lines</span> <span class="o">=</span> <span class="n">infos</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">has_DOSCAR</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_has_DOSCAR</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">has_COHPCAR</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_has_COOPCAR</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">has_COOPCAR</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_has_COHPCAR</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">has_CHARGE</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_has_CHARGE</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">has_Projection</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_has_projection</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">has_bandoverlaps</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_has_bandoverlaps</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">has_fatbands</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_has_fatband</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">has_grosspopulation</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_has_grosspopulation</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">has_density_of_energies</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">_has_density_of_energies</span><span class="p">(</span><span class="n">data</span><span class="o">=</span><span class="n">data</span><span class="p">)</span>

<div class="viewcode-block" id="Lobsterout.get_doc"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Lobsterout.get_doc">[docs]</a>    <span class="k">def</span> <span class="nf">get_doc</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>

<span class="sd">        Returns: LobsterDict with all the information stored in lobsterout</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">LobsterDict</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="c1"># check if Lobster starts from a projection</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;restart_from_projection&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_restart_from_projection</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;lobster_version&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">lobster_version</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;threads&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">number_of_threads</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;Dftprogram&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">dftprogram</span>

        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;chargespilling&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">chargespilling</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;totalspilling&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">totalspilling</span>

        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;elements&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">elements</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;basistype&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">basis_type</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;basisfunctions&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">basis_functions</span>

        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;timing&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">timing</span>

        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;warnings&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">warninglines</span>

        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;orthonormalization&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">info_orthonormalization</span>

        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;infos&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">info_lines</span>

        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;hasDOSCAR&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_DOSCAR</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;hasCOHPCAR&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_COHPCAR</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;hasCOOPCAR&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_COOPCAR</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;hasCHARGE&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_CHARGE</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;hasProjection&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_Projection</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;hasbandoverlaps&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_bandoverlaps</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;hasfatband&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_fatbands</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;hasGrossPopuliation&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_grosspopulation</span>
        <span class="n">LobsterDict</span><span class="p">[</span><span class="s1">&#39;hasDensityOfEnergies&#39;</span><span class="p">]</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">has_density_of_energies</span>

        <span class="k">return</span> <span class="n">LobsterDict</span></div>

    <span class="k">def</span> <span class="nf">_get_lobster_version</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="n">splitrow</span> <span class="o">=</span> <span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">splitrow</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;LOBSTER&quot;</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>

    <span class="k">def</span> <span class="nf">_has_bandoverlaps</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">if</span> <span class="s1">&#39;WARNING: I dumped the band overlap matrices to the file bandOverlaps.lobster.&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="nf">_starts_from_projection</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">if</span> <span class="s1">&#39;loading projection from projectionData.lobster...&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="nf">_has_DOSCAR</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">if</span> <span class="s1">&#39;writing DOSCAR.lobster...&#39;</span> <span class="ow">in</span> <span class="n">data</span> <span class="ow">and</span> <span class="s1">&#39;SKIPPING writing DOSCAR.lobster...&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="nf">_has_COOPCAR</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">if</span> <span class="s1">&#39;writing COOPCAR.lobster and ICOOPLIST.lobster...&#39;</span> <span class="ow">in</span> <span class="n">data</span> <span class="ow">and</span> \
                <span class="s1">&#39;SKIPPING writing COOPCAR.lobster and ICOOPLIST.lobster...&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="nf">_has_COHPCAR</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">if</span> <span class="s1">&#39;writing COHPCAR.lobster and ICOHPLIST.lobster...&#39;</span> <span class="ow">in</span> <span class="n">data</span> <span class="ow">and</span> \
                <span class="s1">&#39;SKIPPING writing COHPCAR.lobster and ICOHPLIST.lobster...&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="nf">_has_CHARGE</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">if</span> <span class="s1">&#39;SKIPPING writing CHARGE.lobster...&#39;</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="nf">_has_grosspopulation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">if</span> <span class="s1">&#39;writing CHARGE.lobster and GROSSPOP.lobster...&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="nf">_has_projection</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">if</span> <span class="s1">&#39;saving projection to projectionData.lobster...&#39;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="nf">_has_fatband</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="n">splitrow</span> <span class="o">=</span> <span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">splitrow</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">1</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;FatBand&#39;</span><span class="p">:</span>
                    <span class="k">return</span> <span class="kc">True</span>
        <span class="k">return</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="nf">_has_density_of_energies</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">if</span> <span class="s2">&quot;writing DensityOfEnergy.lobster...&quot;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">True</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="kc">False</span>

    <span class="k">def</span> <span class="nf">_get_dft_program</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="n">splitrow</span> <span class="o">=</span> <span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">splitrow</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">4</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;program...&quot;</span><span class="p">:</span>
                    <span class="k">return</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">4</span><span class="p">]</span>

    <span class="k">def</span> <span class="nf">_get_number_of_spins</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">if</span> <span class="s2">&quot;spillings for spin channel 2&quot;</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="k">return</span> <span class="mi">2</span>
        <span class="k">else</span><span class="p">:</span>
            <span class="k">return</span> <span class="mi">1</span>

    <span class="k">def</span> <span class="nf">_get_threads</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="n">splitrow</span> <span class="o">=</span> <span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">splitrow</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">11</span><span class="p">:</span>
                <span class="k">if</span> <span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">11</span><span class="p">])</span> <span class="o">==</span> <span class="s2">&quot;threads&quot;</span> <span class="ow">or</span> <span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">11</span><span class="p">]</span> <span class="o">==</span> <span class="s2">&quot;thread&quot;</span><span class="p">):</span>
                    <span class="k">return</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">10</span><span class="p">]</span>

    <span class="k">def</span> <span class="nf">_get_spillings</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">,</span> <span class="n">number_of_spins</span><span class="p">):</span>
        <span class="n">charge_spilling</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">total_spilling</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="n">splitrow</span> <span class="o">=</span> <span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>

            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">splitrow</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">2</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">2</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;spilling:&#39;</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;charge&#39;</span><span class="p">:</span>
                        <span class="n">charge_spilling</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">float</span><span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;%&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">))</span> <span class="o">/</span> <span class="mf">100.0</span><span class="p">)</span>
                    <span class="k">if</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;total&#39;</span><span class="p">:</span>
                        <span class="n">total_spilling</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">np</span><span class="o">.</span><span class="n">float</span><span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">3</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;%&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">))</span> <span class="o">/</span> <span class="mf">100.0</span><span class="p">)</span>

            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">charge_spilling</span><span class="p">)</span> <span class="o">==</span> <span class="n">number_of_spins</span> <span class="ow">and</span> <span class="nb">len</span><span class="p">(</span><span class="n">total_spilling</span><span class="p">)</span> <span class="o">==</span> <span class="n">number_of_spins</span><span class="p">:</span>
                <span class="k">break</span>

        <span class="k">return</span> <span class="n">charge_spilling</span><span class="p">,</span> <span class="n">total_spilling</span>

    <span class="k">def</span> <span class="nf">_get_elements_basistype_basisfunctions</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="n">begin</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">end</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="n">elements</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">basistype</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">basisfunctions</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>

            <span class="k">if</span> <span class="n">begin</span> <span class="ow">and</span> <span class="ow">not</span> <span class="n">end</span><span class="p">:</span>
                <span class="n">splitrow</span> <span class="o">=</span> <span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
                <span class="k">if</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s1">&#39;INFO:&#39;</span><span class="p">,</span> <span class="s1">&#39;WARNING:&#39;</span><span class="p">,</span> <span class="s1">&#39;setting&#39;</span><span class="p">,</span> <span class="s1">&#39;calculating&#39;</span><span class="p">,</span> <span class="s1">&#39;post-processing&#39;</span><span class="p">,</span> <span class="s1">&#39;saving&#39;</span><span class="p">,</span>
                                       <span class="s1">&#39;spillings&#39;</span><span class="p">,</span> <span class="s1">&#39;writing&#39;</span><span class="p">]:</span>

                    <span class="n">elements</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">0</span><span class="p">])</span>
                    <span class="n">basistype</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;(&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">)</span><span class="o">.</span><span class="n">replace</span><span class="p">(</span><span class="s1">&#39;)&#39;</span><span class="p">,</span> <span class="s1">&#39;&#39;</span><span class="p">))</span>
                    <span class="c1"># last sign is a &#39;&#39;</span>
                    <span class="n">basisfunctions</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">2</span><span class="p">:])</span>
                <span class="k">else</span><span class="p">:</span>
                    <span class="n">end</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="k">if</span> <span class="s2">&quot;setting up local basis functions...&quot;</span> <span class="ow">in</span> <span class="n">row</span><span class="p">:</span>
                <span class="n">begin</span> <span class="o">=</span> <span class="kc">True</span>
        <span class="k">return</span> <span class="n">elements</span><span class="p">,</span> <span class="n">basistype</span><span class="p">,</span> <span class="n">basisfunctions</span>

    <span class="k">def</span> <span class="nf">_get_timing</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="c1"># will give back wall, user and sys time</span>
        <span class="n">begin</span> <span class="o">=</span> <span class="kc">False</span>
        <span class="c1"># end=False</span>
        <span class="c1"># time=[]</span>

        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="n">splitrow</span> <span class="o">=</span> <span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="k">if</span> <span class="s1">&#39;finished&#39;</span> <span class="ow">in</span> <span class="n">splitrow</span><span class="p">:</span>
                <span class="n">begin</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="k">if</span> <span class="n">begin</span><span class="p">:</span>
                <span class="k">if</span> <span class="s1">&#39;wall&#39;</span> <span class="ow">in</span> <span class="n">splitrow</span><span class="p">:</span>
                    <span class="n">wall_time</span> <span class="o">=</span> <span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">2</span><span class="p">:</span><span class="mi">10</span><span class="p">])</span>
                <span class="k">if</span> <span class="s1">&#39;user&#39;</span> <span class="ow">in</span> <span class="n">splitrow</span><span class="p">:</span>
                    <span class="n">user_time</span> <span class="o">=</span> <span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">8</span><span class="p">])</span>
                <span class="k">if</span> <span class="s1">&#39;sys&#39;</span> <span class="ow">in</span> <span class="n">splitrow</span><span class="p">:</span>
                    <span class="n">sys_time</span> <span class="o">=</span> <span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">0</span><span class="p">:</span><span class="mi">8</span><span class="p">])</span>

        <span class="n">wall_time_dict</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;h&quot;</span><span class="p">:</span> <span class="n">wall_time</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s2">&quot;min&quot;</span><span class="p">:</span> <span class="n">wall_time</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="s2">&quot;s&quot;</span><span class="p">:</span> <span class="n">wall_time</span><span class="p">[</span><span class="mi">4</span><span class="p">],</span> <span class="s2">&quot;ms&quot;</span><span class="p">:</span> <span class="n">wall_time</span><span class="p">[</span><span class="mi">6</span><span class="p">]}</span>
        <span class="n">user_time_dict</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;h&quot;</span><span class="p">:</span> <span class="n">user_time</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s2">&quot;min&quot;</span><span class="p">:</span> <span class="n">user_time</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="s2">&quot;s&quot;</span><span class="p">:</span> <span class="n">user_time</span><span class="p">[</span><span class="mi">4</span><span class="p">],</span> <span class="s2">&quot;ms&quot;</span><span class="p">:</span> <span class="n">user_time</span><span class="p">[</span><span class="mi">6</span><span class="p">]}</span>
        <span class="n">sys_time_dict</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;h&quot;</span><span class="p">:</span> <span class="n">sys_time</span><span class="p">[</span><span class="mi">0</span><span class="p">],</span> <span class="s2">&quot;min&quot;</span><span class="p">:</span> <span class="n">sys_time</span><span class="p">[</span><span class="mi">2</span><span class="p">],</span> <span class="s2">&quot;s&quot;</span><span class="p">:</span> <span class="n">sys_time</span><span class="p">[</span><span class="mi">4</span><span class="p">],</span> <span class="s2">&quot;ms&quot;</span><span class="p">:</span> <span class="n">sys_time</span><span class="p">[</span><span class="mi">6</span><span class="p">]}</span>

        <span class="k">return</span> <span class="n">wall_time_dict</span><span class="p">,</span> <span class="n">user_time_dict</span><span class="p">,</span> <span class="n">sys_time_dict</span>

    <span class="k">def</span> <span class="nf">_get_warning_orthonormalization</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="n">orthowarning</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="n">splitrow</span> <span class="o">=</span> <span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="k">if</span> <span class="s1">&#39;orthonormalized&#39;</span> <span class="ow">in</span> <span class="n">splitrow</span><span class="p">:</span>
                <span class="n">orthowarning</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">1</span><span class="p">:]))</span>
        <span class="k">return</span> <span class="n">orthowarning</span>

    <span class="k">def</span> <span class="nf">_get_all_warning_lines</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="n">warnings</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="n">splitrow</span> <span class="o">=</span> <span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">splitrow</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;WARNING:&#39;</span><span class="p">:</span>
                    <span class="n">warnings</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">1</span><span class="p">:]))</span>

        <span class="k">return</span> <span class="n">warnings</span>

    <span class="k">def</span> <span class="nf">_get_all_info_lines</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">data</span><span class="p">):</span>
        <span class="n">infos</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">row</span> <span class="ow">in</span> <span class="n">data</span><span class="p">:</span>
            <span class="n">splitrow</span> <span class="o">=</span> <span class="n">row</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">splitrow</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">splitrow</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;INFO:&#39;</span><span class="p">:</span>
                    <span class="n">infos</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">splitrow</span><span class="p">[</span><span class="mi">1</span><span class="p">:]))</span>

        <span class="k">return</span> <span class="n">infos</span></div>


<div class="viewcode-block" id="Fatband"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Fatband">[docs]</a><span class="k">class</span> <span class="nc">Fatband</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Reads in FATBAND_x_y.lobster files</span>

<span class="sd">    .. attribute: efermi</span>

<span class="sd">        efermi that was read in from vasprun.xml</span>

<span class="sd">    .. attribute: eigenvals</span>
<span class="sd">        {Spin.up:[][],Spin.down:[][]}, the first index of the array</span>
<span class="sd">            [][] refers to the band and the second to the index of the</span>
<span class="sd">            kpoint. The kpoints are ordered according to the order of the</span>
<span class="sd">            kpoints array. If the band structure is not spin polarized, we</span>
<span class="sd">            only store one data set under Spin.up.</span>

<span class="sd">    .. attribute: is_spinpolarized</span>

<span class="sd">        Boolean that tells you whether this was a spin-polarized calculation</span>

<span class="sd">    .. attribute: kpoints_array</span>

<span class="sd">        list of kpoint as numpy arrays, in frac_coords of the given lattice by default</span>

<span class="sd">    .. attribute: label_dict</span>

<span class="sd">         (dict) of {} this link a kpoint (in frac coords or cartesian coordinates depending on the coords).</span>

<span class="sd">    .. attribute: lattice</span>

<span class="sd">        lattice object of reciprocal lattice as read in from vasprun.xml</span>

<span class="sd">    .. attribute: nbands</span>

<span class="sd">        number of bands used in the calculation</span>

<span class="sd">    .. attribute: p_eigenvals</span>

<span class="sd">        dict of orbital projections as {spin: array of dict}.</span>
<span class="sd">        The indices of the array are [band_index, kpoint_index].</span>
<span class="sd">        The dict is then built the following way:</span>
<span class="sd">        {&quot;string of element&quot;: &quot;string of orbital as read in from FATBAND file&quot;}</span>
<span class="sd">        If the band structure is not spin polarized, we only store one data set under Spin.up.</span>

<span class="sd">    .. attribute: structure</span>

<span class="sd">        structure read in from vasprun.xml</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filenames</span><span class="o">=</span><span class="s2">&quot;.&quot;</span><span class="p">,</span> <span class="n">vasprun</span><span class="o">=</span><span class="s1">&#39;vasprun.xml&#39;</span><span class="p">,</span> <span class="n">Kpointsfile</span><span class="o">=</span><span class="s1">&#39;KPOINTS&#39;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            filenames (list or string): can be a list of file names or a path to a folder folder from which all</span>
<span class="sd">                &quot;FATBAND_*&quot; files will be read</span>
<span class="sd">            vasprun: corresponding vasprun file</span>
<span class="sd">            Kpointsfile: KPOINTS file for bandstructure calculation, typically &quot;KPOINTS&quot;</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s1">&#39;Make sure all relevant FATBAND files were generated and read in!&#39;</span><span class="p">)</span>
        <span class="n">warnings</span><span class="o">.</span><span class="n">warn</span><span class="p">(</span><span class="s1">&#39;Use Lobster 3.2.0 or newer for fatband calculations!&#39;</span><span class="p">)</span>

        <span class="n">VASPRUN</span> <span class="o">=</span> <span class="n">Vasprun</span><span class="p">(</span><span class="n">filename</span><span class="o">=</span><span class="n">vasprun</span><span class="p">,</span> <span class="n">ionic_step_skip</span><span class="o">=</span><span class="kc">None</span><span class="p">,</span>
                          <span class="n">ionic_step_offset</span><span class="o">=</span><span class="mi">0</span><span class="p">,</span> <span class="n">parse_dos</span><span class="o">=</span><span class="kc">True</span><span class="p">,</span>
                          <span class="n">parse_eigen</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">parse_projected_eigen</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span>
                          <span class="n">parse_potcar_file</span><span class="o">=</span><span class="kc">False</span><span class="p">,</span> <span class="n">occu_tol</span><span class="o">=</span><span class="mf">1e-8</span><span class="p">,</span>
                          <span class="n">exception_on_bad_xml</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">structure</span> <span class="o">=</span> <span class="n">VASPRUN</span><span class="o">.</span><span class="n">final_structure</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">lattice</span> <span class="o">=</span> <span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="o">.</span><span class="n">lattice</span><span class="o">.</span><span class="n">reciprocal_lattice</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">efermi</span> <span class="o">=</span> <span class="n">VASPRUN</span><span class="o">.</span><span class="n">efermi</span>
        <span class="n">kpoints_object</span> <span class="o">=</span> <span class="n">Kpoints</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">Kpointsfile</span><span class="p">)</span>

        <span class="n">atomtype</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">atomnames</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">orbital_names</span> <span class="o">=</span> <span class="p">[]</span>

        <span class="k">if</span> <span class="ow">not</span> <span class="nb">isinstance</span><span class="p">(</span><span class="n">filenames</span><span class="p">,</span> <span class="nb">list</span><span class="p">)</span> <span class="ow">or</span> <span class="n">filenames</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
            <span class="n">filenames_new</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">if</span> <span class="n">filenames</span> <span class="ow">is</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">filenames</span> <span class="o">=</span> <span class="s1">&#39;.&#39;</span>
            <span class="k">for</span> <span class="n">file</span> <span class="ow">in</span> <span class="n">os</span><span class="o">.</span><span class="n">listdir</span><span class="p">(</span><span class="n">filenames</span><span class="p">):</span>
                <span class="k">if</span> <span class="n">fnmatch</span><span class="o">.</span><span class="n">fnmatch</span><span class="p">(</span><span class="n">file</span><span class="p">,</span> <span class="s1">&#39;FATBAND_*.lobster&#39;</span><span class="p">):</span>
                    <span class="n">filenames_new</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">filenames</span><span class="p">,</span> <span class="n">file</span><span class="p">))</span>
            <span class="n">filenames</span> <span class="o">=</span> <span class="n">filenames_new</span>
        <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">filenames</span><span class="p">)</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
            <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;No FATBAND files in folder or given&quot;</span><span class="p">)</span>
        <span class="k">for</span> <span class="n">ifilename</span><span class="p">,</span> <span class="n">filename</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">filenames</span><span class="p">):</span>
            <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s2">&quot;rt&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                <span class="n">contents</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

            <span class="c1"># TODO: could be replaced for future versions of Lobster, get atomname from filename</span>
            <span class="n">atomnames</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">os</span><span class="o">.</span><span class="n">path</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="n">filename</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s1">&#39;_&#39;</span><span class="p">)[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">capitalize</span><span class="p">())</span>
            <span class="n">parameters</span> <span class="o">=</span> <span class="n">contents</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">()</span>
            <span class="n">atomtype</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">re</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="sa">r</span><span class="s2">&quot;[0-9]+&quot;</span><span class="p">,</span> <span class="n">parameters</span><span class="p">[</span><span class="mi">3</span><span class="p">])[</span><span class="mi">0</span><span class="p">]</span><span class="o">.</span><span class="n">capitalize</span><span class="p">())</span>
            <span class="n">orbital_names</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">4</span><span class="p">])</span>

        <span class="c1"># get atomtype orbital dict</span>
        <span class="n">atom_orbital_dict</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">iatom</span><span class="p">,</span> <span class="n">atom</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">atomnames</span><span class="p">):</span>
            <span class="k">if</span> <span class="n">atom</span> <span class="ow">not</span> <span class="ow">in</span> <span class="n">atom_orbital_dict</span><span class="p">:</span>
                <span class="n">atom_orbital_dict</span><span class="p">[</span><span class="n">atom</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="n">atom_orbital_dict</span><span class="p">[</span><span class="n">atom</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">orbital_names</span><span class="p">[</span><span class="n">iatom</span><span class="p">])</span>
        <span class="c1"># test if there are the same orbitals twice or if two different formats were used or if all necessary orbitals</span>
        <span class="c1"># are there</span>
        <span class="k">for</span> <span class="n">key</span><span class="p">,</span> <span class="n">items</span> <span class="ow">in</span> <span class="n">atom_orbital_dict</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="nb">set</span><span class="p">(</span><span class="n">items</span><span class="p">))</span> <span class="o">!=</span> <span class="nb">len</span><span class="p">(</span><span class="n">items</span><span class="p">):</span>
                <span class="k">raise</span> <span class="p">(</span><span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;The are two FATBAND files for the same atom and orbital. The program will stop.&quot;</span><span class="p">))</span>
            <span class="n">split</span> <span class="o">=</span> <span class="p">[]</span>
            <span class="k">for</span> <span class="n">item</span> <span class="ow">in</span> <span class="n">items</span><span class="p">:</span>
                <span class="n">split</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">item</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;_&quot;</span><span class="p">)[</span><span class="mi">0</span><span class="p">])</span>
            <span class="k">for</span> <span class="n">orb</span><span class="p">,</span> <span class="n">number</span> <span class="ow">in</span> <span class="n">collections</span><span class="o">.</span><span class="n">Counter</span><span class="p">(</span><span class="n">split</span><span class="p">)</span><span class="o">.</span><span class="n">items</span><span class="p">():</span>
                <span class="k">if</span> <span class="n">number</span> <span class="o">!=</span> <span class="mi">1</span> <span class="ow">and</span> <span class="n">number</span> <span class="o">!=</span> <span class="mi">3</span> <span class="ow">and</span> <span class="n">number</span> <span class="o">!=</span> <span class="mi">5</span> <span class="ow">and</span> <span class="n">number</span> <span class="o">!=</span> <span class="mi">7</span><span class="p">:</span>
                    <span class="k">raise</span> <span class="ne">ValueError</span><span class="p">(</span>
                        <span class="s2">&quot;Make sure all relevant orbitals were generated and that no duplicates (2p and 2p_x) are &quot;</span>
                        <span class="s2">&quot;present&quot;</span><span class="p">)</span>

        <span class="n">kpoints_array</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">ifilename</span><span class="p">,</span> <span class="n">filename</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">filenames</span><span class="p">):</span>
            <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s2">&quot;rt&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
                <span class="n">contents</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

            <span class="k">if</span> <span class="n">ifilename</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">nbands</span> <span class="o">=</span> <span class="nb">int</span><span class="p">(</span><span class="n">parameters</span><span class="p">[</span><span class="mi">6</span><span class="p">])</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">number_kpts</span> <span class="o">=</span> <span class="n">kpoints_object</span><span class="o">.</span><span class="n">num_kpts</span> <span class="o">-</span> <span class="nb">int</span><span class="p">(</span><span class="n">contents</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">2</span><span class="p">])</span> <span class="o">+</span> <span class="mi">1</span>

            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">contents</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">nbands</span> <span class="o">+</span> <span class="mi">2</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">is_spinpolarized</span> <span class="o">=</span> <span class="kc">False</span>
            <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">contents</span><span class="p">[</span><span class="mi">1</span><span class="p">:])</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">nbands</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">+</span> <span class="mi">2</span><span class="p">:</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">is_spinpolarized</span> <span class="o">=</span> <span class="kc">True</span>
            <span class="k">else</span><span class="p">:</span>
                <span class="n">linenumbers</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">iline</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">contents</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="bp">self</span><span class="o">.</span><span class="n">nbands</span> <span class="o">*</span> <span class="mi">2</span> <span class="o">+</span> <span class="mi">4</span><span class="p">]):</span>
                    <span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;#&#39;</span><span class="p">:</span>
                        <span class="n">linenumbers</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">iline</span><span class="p">)</span>

                <span class="k">if</span> <span class="n">ifilename</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                    <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">linenumbers</span><span class="p">)</span> <span class="o">==</span> <span class="mi">2</span><span class="p">:</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">is_spinpolarized</span> <span class="o">=</span> <span class="kc">True</span>
                    <span class="k">else</span><span class="p">:</span>
                        <span class="bp">self</span><span class="o">.</span><span class="n">is_spinpolarized</span> <span class="o">=</span> <span class="kc">False</span>

            <span class="k">if</span> <span class="n">ifilename</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">eigenvals</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="n">eigenvals</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span> <span class="o">=</span> <span class="p">[[</span><span class="n">collections</span><span class="o">.</span><span class="n">defaultdict</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>
                                       <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">number_kpts</span><span class="p">)]</span>
                                      <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nbands</span><span class="p">)]</span>
                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_spinpolarized</span><span class="p">:</span>
                    <span class="n">eigenvals</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]</span> <span class="o">=</span> <span class="p">[[</span><span class="n">collections</span><span class="o">.</span><span class="n">defaultdict</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span>
                                             <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">number_kpts</span><span class="p">)]</span>
                                            <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nbands</span><span class="p">)]</span>

                <span class="n">p_eigenvals</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="n">p_eigenvals</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span>
                    <span class="p">[{</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">):</span> <span class="p">{</span><span class="nb">str</span><span class="p">(</span><span class="n">orb</span><span class="p">):</span> <span class="n">collections</span><span class="o">.</span><span class="n">defaultdict</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span> <span class="k">for</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">atom_orbital_dict</span><span class="p">[</span><span class="n">e</span><span class="p">]}</span>
                      <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">atomnames</span><span class="p">}</span>
                     <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">number_kpts</span><span class="p">)]</span>
                    <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nbands</span><span class="p">)]</span>

                <span class="k">if</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_spinpolarized</span><span class="p">:</span>
                    <span class="n">p_eigenvals</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]</span> <span class="o">=</span> <span class="p">[</span>
                        <span class="p">[{</span><span class="nb">str</span><span class="p">(</span><span class="n">e</span><span class="p">):</span> <span class="p">{</span><span class="nb">str</span><span class="p">(</span><span class="n">orb</span><span class="p">):</span> <span class="n">collections</span><span class="o">.</span><span class="n">defaultdict</span><span class="p">(</span><span class="nb">float</span><span class="p">)</span> <span class="k">for</span> <span class="n">orb</span> <span class="ow">in</span> <span class="n">atom_orbital_dict</span><span class="p">[</span><span class="n">e</span><span class="p">]}</span>
                          <span class="k">for</span> <span class="n">e</span> <span class="ow">in</span> <span class="n">atomnames</span><span class="p">}</span>
                         <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">number_kpts</span><span class="p">)]</span>
                        <span class="k">for</span> <span class="n">j</span> <span class="ow">in</span> <span class="nb">range</span><span class="p">(</span><span class="bp">self</span><span class="o">.</span><span class="n">nbands</span><span class="p">)]</span>

            <span class="n">ikpoint</span> <span class="o">=</span> <span class="o">-</span><span class="mi">1</span>
            <span class="k">for</span> <span class="n">iline</span><span class="p">,</span> <span class="n">line</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">contents</span><span class="p">[</span><span class="mi">1</span><span class="p">:</span><span class="o">-</span><span class="mi">1</span><span class="p">]):</span>
                <span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> <span class="o">==</span> <span class="s1">&#39;#&#39;</span><span class="p">:</span>
                    <span class="n">KPOINT</span> <span class="o">=</span> <span class="n">np</span><span class="o">.</span><span class="n">array</span><span class="p">([</span><span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">4</span><span class="p">]),</span> <span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">5</span><span class="p">]),</span> <span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">6</span><span class="p">])])</span>
                    <span class="k">if</span> <span class="n">ifilename</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                        <span class="n">kpoints_array</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">KPOINT</span><span class="p">)</span>

                    <span class="n">linenumber</span> <span class="o">=</span> <span class="mi">0</span>
                    <span class="n">iband</span> <span class="o">=</span> <span class="mi">0</span>
                    <span class="n">ikpoint</span> <span class="o">+=</span> <span class="mi">1</span>
                <span class="k">if</span> <span class="n">linenumber</span> <span class="o">==</span> <span class="bp">self</span><span class="o">.</span><span class="n">nbands</span><span class="p">:</span>
                    <span class="n">iband</span> <span class="o">=</span> <span class="mi">0</span>
                <span class="k">if</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">0</span><span class="p">]</span> <span class="o">!=</span> <span class="s1">&#39;#&#39;</span><span class="p">:</span>

                    <span class="k">if</span> <span class="n">linenumber</span> <span class="o">&lt;</span> <span class="bp">self</span><span class="o">.</span><span class="n">nbands</span><span class="p">:</span>
                        <span class="k">if</span> <span class="n">ifilename</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                            <span class="n">eigenvals</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">][</span><span class="n">iband</span><span class="p">][</span><span class="n">ikpoint</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">1</span><span class="p">])</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">efermi</span>

                        <span class="n">p_eigenvals</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">][</span><span class="n">iband</span><span class="p">][</span><span class="n">ikpoint</span><span class="p">][</span><span class="n">atomnames</span><span class="p">[</span><span class="n">ifilename</span><span class="p">]][</span><span class="n">orbital_names</span><span class="p">[</span><span class="n">ifilename</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span>
                            <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">2</span><span class="p">])</span>
                    <span class="k">if</span> <span class="n">linenumber</span> <span class="o">&gt;=</span> <span class="bp">self</span><span class="o">.</span><span class="n">nbands</span> <span class="ow">and</span> <span class="bp">self</span><span class="o">.</span><span class="n">is_spinpolarized</span><span class="p">:</span>
                        <span class="k">if</span> <span class="n">ifilename</span> <span class="o">==</span> <span class="mi">0</span><span class="p">:</span>
                            <span class="n">eigenvals</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">][</span><span class="n">iband</span><span class="p">][</span><span class="n">ikpoint</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">1</span><span class="p">])</span> <span class="o">+</span> <span class="bp">self</span><span class="o">.</span><span class="n">efermi</span>
                        <span class="n">p_eigenvals</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">][</span><span class="n">iband</span><span class="p">][</span><span class="n">ikpoint</span><span class="p">][</span><span class="n">atomnames</span><span class="p">[</span><span class="n">ifilename</span><span class="p">]][</span>
                            <span class="n">orbital_names</span><span class="p">[</span><span class="n">ifilename</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">()[</span><span class="mi">2</span><span class="p">])</span>

                    <span class="n">linenumber</span> <span class="o">+=</span> <span class="mi">1</span>
                    <span class="n">iband</span> <span class="o">+=</span> <span class="mi">1</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">kpoints_array</span> <span class="o">=</span> <span class="n">kpoints_array</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">eigenvals</span> <span class="o">=</span> <span class="n">eigenvals</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">p_eigenvals</span> <span class="o">=</span> <span class="n">p_eigenvals</span>

        <span class="n">label_dict</span> <span class="o">=</span> <span class="p">{}</span>
        <span class="k">for</span> <span class="n">ilabel</span><span class="p">,</span> <span class="n">label</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">kpoints_object</span><span class="o">.</span><span class="n">labels</span><span class="p">[</span><span class="o">-</span><span class="bp">self</span><span class="o">.</span><span class="n">number_kpts</span><span class="p">:],</span> <span class="n">start</span><span class="o">=</span><span class="mi">0</span><span class="p">):</span>

            <span class="k">if</span> <span class="n">label</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                <span class="n">label_dict</span><span class="p">[</span><span class="n">label</span><span class="p">]</span> <span class="o">=</span> <span class="n">kpoints_array</span><span class="p">[</span><span class="n">ilabel</span><span class="p">]</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">label_dict</span> <span class="o">=</span> <span class="n">label_dict</span>

<div class="viewcode-block" id="Fatband.get_bandstructure"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Fatband.get_bandstructure">[docs]</a>    <span class="k">def</span> <span class="nf">get_bandstructure</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        returns a LobsterBandStructureSymmLine object which can be plotted with a normal BSPlotter</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">return</span> <span class="n">LobsterBandStructureSymmLine</span><span class="p">(</span><span class="n">kpoints</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">kpoints_array</span><span class="p">,</span> <span class="n">eigenvals</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">eigenvals</span><span class="p">,</span> <span class="n">lattice</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">lattice</span><span class="p">,</span>
                                            <span class="n">efermi</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">efermi</span><span class="p">,</span> <span class="n">labels_dict</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">label_dict</span><span class="p">,</span>
                                            <span class="n">structure</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">structure</span><span class="p">,</span>
                                            <span class="n">projections</span><span class="o">=</span><span class="bp">self</span><span class="o">.</span><span class="n">p_eigenvals</span><span class="p">)</span></div></div>


<div class="viewcode-block" id="Bandoverlaps"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Bandoverlaps">[docs]</a><span class="k">class</span> <span class="nc">Bandoverlaps</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class to read in bandOverlaps.lobster files. These files are not created during every Lobster run.</span>
<span class="sd">    .. attribute: bandoverlapsdict is a dict of the following form:</span>
<span class="sd">        {spin:{&quot;kpoint as string&quot;: {&quot;maxDeviation&quot;: float that describes the max deviation, &quot;matrix&quot;: 2D</span>
<span class="sd">        array of the size number of bands times number of bands including the overlap matrices with } }}</span>

<span class="sd">    .. attribute: maxDeviation is a list of floats describing the maximal Deviation for each problematic kpoint</span>

<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;bandOverlaps.lobster&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            filename: filename of the &quot;bandOverlaps.lobster&quot; file</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s2">&quot;rt&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">contents</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">_read</span><span class="p">(</span><span class="n">contents</span><span class="p">)</span>

    <span class="k">def</span> <span class="nf">_read</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">contents</span><span class="p">:</span> <span class="nb">list</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        will read in all contents of the file</span>
<span class="sd">        Args:</span>
<span class="sd">         contents: list of strings</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">bandoverlapsdict</span> <span class="o">=</span> <span class="p">{}</span>  <span class="c1"># type: Dict</span>
        <span class="bp">self</span><span class="o">.</span><span class="n">max_deviation</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># type: List</span>
        <span class="c1"># This has to be done like this because there can be different numbers of problematic k-points per spin</span>
        <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">contents</span><span class="p">:</span>
            <span class="k">if</span> <span class="s2">&quot;Overlap Matrix (abs) of the orthonormalized projected bands for spin 0&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                <span class="n">spin</span> <span class="o">=</span> <span class="n">Spin</span><span class="o">.</span><span class="n">up</span>
            <span class="k">elif</span> <span class="s2">&quot;Overlap Matrix (abs) of the orthonormalized projected bands for spin 1&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                <span class="n">spin</span> <span class="o">=</span> <span class="n">Spin</span><span class="o">.</span><span class="n">down</span>
            <span class="k">elif</span> <span class="s2">&quot;k-point&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                <span class="n">kpoint</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">)</span>
                <span class="n">kpoint_array</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">kpointel</span> <span class="ow">in</span> <span class="n">kpoint</span><span class="p">:</span>
                    <span class="k">if</span> <span class="n">kpointel</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;at&quot;</span><span class="p">,</span> <span class="s2">&quot;k-point&quot;</span><span class="p">,</span> <span class="s2">&quot;&quot;</span><span class="p">]:</span>
                        <span class="n">kpoint_array</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">str</span><span class="p">(</span><span class="n">kpointel</span><span class="p">))</span>

            <span class="k">elif</span> <span class="s2">&quot;maxDeviation&quot;</span> <span class="ow">in</span> <span class="n">line</span><span class="p">:</span>
                <span class="k">if</span> <span class="n">spin</span> <span class="ow">not</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">bandoverlapsdict</span><span class="p">:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">bandoverlapsdict</span><span class="p">[</span><span class="n">spin</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="k">if</span> <span class="ow">not</span> <span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kpoint_array</span><span class="p">)</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">bandoverlapsdict</span><span class="p">[</span><span class="n">spin</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">bandoverlapsdict</span><span class="p">[</span><span class="n">spin</span><span class="p">][</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kpoint_array</span><span class="p">)]</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="n">maxdev</span> <span class="o">=</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">)[</span><span class="mi">2</span><span class="p">]</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">bandoverlapsdict</span><span class="p">[</span><span class="n">spin</span><span class="p">][</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kpoint_array</span><span class="p">)][</span><span class="s2">&quot;maxDeviation&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">maxdev</span><span class="p">)</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">max_deviation</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">maxdev</span><span class="p">))</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">bandoverlapsdict</span><span class="p">[</span><span class="n">spin</span><span class="p">][</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kpoint_array</span><span class="p">)][</span><span class="s2">&quot;matrix&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">[]</span>

            <span class="k">else</span><span class="p">:</span>
                <span class="n">overlaps</span> <span class="o">=</span> <span class="p">[]</span>
                <span class="k">for</span> <span class="n">el</span> <span class="ow">in</span> <span class="p">(</span><span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">)):</span>
                    <span class="k">if</span> <span class="n">el</span> <span class="ow">not</span> <span class="ow">in</span> <span class="p">[</span><span class="s2">&quot;&quot;</span><span class="p">]:</span>
                        <span class="n">overlaps</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="nb">float</span><span class="p">(</span><span class="n">el</span><span class="p">))</span>
                <span class="bp">self</span><span class="o">.</span><span class="n">bandoverlapsdict</span><span class="p">[</span><span class="n">spin</span><span class="p">][</span><span class="s2">&quot; &quot;</span><span class="o">.</span><span class="n">join</span><span class="p">(</span><span class="n">kpoint_array</span><span class="p">)][</span><span class="s2">&quot;matrix&quot;</span><span class="p">]</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">overlaps</span><span class="p">)</span>

<div class="viewcode-block" id="Bandoverlaps.has_good_quality_maxDeviation"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Bandoverlaps.has_good_quality_maxDeviation">[docs]</a>    <span class="k">def</span> <span class="nf">has_good_quality_maxDeviation</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">limit_maxDeviation</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.1</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        will check if the maxDeviation from the ideal bandoverlap is smaller or equal to limit_maxDeviation</span>
<span class="sd">        Args:</span>
<span class="sd">         limit_maxDeviation: limit of the maxDeviation</span>
<span class="sd">        Returns:</span>
<span class="sd">             Boolean that will give you information about the quality of the projection</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">for</span> <span class="n">deviation</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">max_deviation</span><span class="p">:</span>
            <span class="k">if</span> <span class="n">deviation</span> <span class="o">&gt;</span> <span class="n">limit_maxDeviation</span><span class="p">:</span>
                <span class="k">return</span> <span class="kc">False</span>
        <span class="k">return</span> <span class="kc">True</span></div>

<div class="viewcode-block" id="Bandoverlaps.has_good_quality_check_occupied_bands"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Bandoverlaps.has_good_quality_check_occupied_bands">[docs]</a>    <span class="k">def</span> <span class="nf">has_good_quality_check_occupied_bands</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">number_occ_bands_spin_up</span><span class="p">:</span> <span class="nb">int</span><span class="p">,</span>
                                              <span class="n">number_occ_bands_spin_down</span><span class="p">:</span> <span class="n">Optional</span><span class="p">[</span><span class="nb">int</span><span class="p">]</span> <span class="o">=</span> <span class="kc">None</span><span class="p">,</span>
                                              <span class="n">spin_polarized</span><span class="p">:</span> <span class="nb">bool</span> <span class="o">=</span> <span class="kc">False</span><span class="p">,</span> <span class="n">limit_deviation</span><span class="p">:</span> <span class="nb">float</span> <span class="o">=</span> <span class="mf">0.1</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="nb">bool</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        will check if the deviation from the ideal bandoverlap of all occupied bands is smaller or equal to</span>
<span class="sd">        limit_deviation</span>

<span class="sd">        Args:</span>
<span class="sd">        number_occ_bands_spin_up (int): number of occupied bands of spin up</span>
<span class="sd">        number_occ_bands_spin_down (int): number of occupied bands of spin down</span>
<span class="sd">        spin_polarized (bool):  If True, then it was a spin polarized calculation</span>
<span class="sd">        limit_deviation (float): limit of the maxDeviation</span>
<span class="sd">        Returns:</span>
<span class="sd">             Boolean that will give you information about the quality of the projection</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="k">for</span> <span class="n">matrix</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">bandoverlapsdict</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">up</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
            <span class="k">for</span> <span class="n">iband1</span><span class="p">,</span> <span class="n">band1</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">matrix</span><span class="p">[</span><span class="s2">&quot;matrix&quot;</span><span class="p">]):</span>
                <span class="k">for</span> <span class="n">iband2</span><span class="p">,</span> <span class="n">band2</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">band1</span><span class="p">):</span>
                    <span class="k">if</span> <span class="n">iband1</span> <span class="o">&lt;</span> <span class="n">number_occ_bands_spin_up</span> <span class="ow">and</span> <span class="n">iband2</span> <span class="o">&lt;</span> <span class="n">number_occ_bands_spin_up</span><span class="p">:</span>
                        <span class="k">if</span> <span class="n">iband1</span> <span class="o">==</span> <span class="n">iband2</span><span class="p">:</span>
                            <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="n">band2</span> <span class="o">-</span> <span class="mf">1.0</span><span class="p">)</span> <span class="o">&gt;</span> <span class="n">limit_deviation</span><span class="p">:</span>
                                <span class="k">return</span> <span class="kc">False</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="k">if</span> <span class="n">band2</span> <span class="o">&gt;</span> <span class="n">limit_deviation</span><span class="p">:</span>
                                <span class="k">return</span> <span class="kc">False</span>

        <span class="k">if</span> <span class="n">spin_polarized</span><span class="p">:</span>
            <span class="k">for</span> <span class="n">matrix</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">bandoverlapsdict</span><span class="p">[</span><span class="n">Spin</span><span class="o">.</span><span class="n">down</span><span class="p">]</span><span class="o">.</span><span class="n">values</span><span class="p">():</span>
                <span class="k">for</span> <span class="n">iband1</span><span class="p">,</span> <span class="n">band1</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">matrix</span><span class="p">[</span><span class="s2">&quot;matrix&quot;</span><span class="p">]):</span>
                    <span class="k">for</span> <span class="n">iband2</span><span class="p">,</span> <span class="n">band2</span> <span class="ow">in</span> <span class="nb">enumerate</span><span class="p">(</span><span class="n">band1</span><span class="p">):</span>
                        <span class="k">if</span> <span class="n">number_occ_bands_spin_down</span> <span class="ow">is</span> <span class="ow">not</span> <span class="kc">None</span><span class="p">:</span>
                            <span class="k">if</span> <span class="n">iband1</span> <span class="o">&lt;</span> <span class="n">number_occ_bands_spin_down</span> <span class="ow">and</span> <span class="n">iband2</span> <span class="o">&lt;</span> <span class="n">number_occ_bands_spin_down</span><span class="p">:</span>
                                <span class="k">if</span> <span class="n">iband1</span> <span class="o">==</span> <span class="n">iband2</span><span class="p">:</span>
                                    <span class="k">if</span> <span class="nb">abs</span><span class="p">(</span><span class="n">band2</span> <span class="o">-</span> <span class="mf">1.0</span><span class="p">)</span> <span class="o">&gt;</span> <span class="n">limit_deviation</span><span class="p">:</span>
                                        <span class="k">return</span> <span class="kc">False</span>
                                <span class="k">else</span><span class="p">:</span>
                                    <span class="k">if</span> <span class="n">band2</span> <span class="o">&gt;</span> <span class="n">limit_deviation</span><span class="p">:</span>
                                        <span class="k">return</span> <span class="kc">False</span>
                        <span class="k">else</span><span class="p">:</span>
                            <span class="ne">ValueError</span><span class="p">(</span><span class="s2">&quot;number_occ_bands_spin_down has to be specified&quot;</span><span class="p">)</span>
        <span class="k">return</span> <span class="kc">True</span></div></div>


<div class="viewcode-block" id="Grosspop"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Grosspop">[docs]</a><span class="k">class</span> <span class="nc">Grosspop</span><span class="p">:</span>
    <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">    Class to read in GROSSPOP.lobster files.</span>

<span class="sd">    .. attribute: list_dict_grosspop</span>
<span class="sd">       which is a list of dicts including all information about the grosspopulations, one sample dict looks like this:</span>
<span class="sd">        {&#39;element&#39;: &#39;O&#39;, &#39;Mulliken GP&#39;: {&#39;2s&#39;: &#39;1.80&#39;, &#39;2p_y&#39;: &#39;1.83&#39;, &#39;2p_z&#39;: &#39;1.79&#39;, &#39;2p_x&#39;: &#39;1.75&#39;, &#39;total&#39;: &#39;7.18&#39;},</span>
<span class="sd">         &#39;Loewdin GP&#39;: {&#39;2s&#39;: &#39;1.60&#39;, &#39;2p_y&#39;: &#39;1.82&#39;, &#39;2p_z&#39;: &#39;1.77&#39;, &#39;2p_x&#39;: &#39;1.73&#39;, &#39;total&#39;: &#39;6.92&#39;}}</span>
<span class="sd">        The 0. entry of the list refers to the first atom in GROSSPOP.lobster and so on.</span>
<span class="sd">    &quot;&quot;&quot;</span>

    <span class="k">def</span> <span class="fm">__init__</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">filename</span><span class="p">:</span> <span class="nb">str</span> <span class="o">=</span> <span class="s2">&quot;GROSSPOP.lobster&quot;</span><span class="p">):</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        Args:</span>
<span class="sd">            filename: filename of the &quot;GROSSPOP.lobster&quot; file</span>
<span class="sd">        &quot;&quot;&quot;</span>
        <span class="c1"># opens file</span>
        <span class="k">with</span> <span class="n">zopen</span><span class="p">(</span><span class="n">filename</span><span class="p">,</span> <span class="s2">&quot;rt&quot;</span><span class="p">)</span> <span class="k">as</span> <span class="n">f</span><span class="p">:</span>
            <span class="n">contents</span> <span class="o">=</span> <span class="n">f</span><span class="o">.</span><span class="n">read</span><span class="p">()</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot;</span><span class="se">\n</span><span class="s2">&quot;</span><span class="p">)</span>

        <span class="bp">self</span><span class="o">.</span><span class="n">list_dict_grosspop</span> <span class="o">=</span> <span class="p">[]</span>  <span class="c1"># type: List[Any]</span>
        <span class="c1"># transfers content of file to list of dict</span>
        <span class="k">for</span> <span class="n">line</span> <span class="ow">in</span> <span class="n">contents</span><span class="p">[</span><span class="mi">3</span><span class="p">:]:</span>
            <span class="n">cleanline</span> <span class="o">=</span> <span class="p">[</span><span class="n">i</span> <span class="k">for</span> <span class="n">i</span> <span class="ow">in</span> <span class="n">line</span><span class="o">.</span><span class="n">split</span><span class="p">(</span><span class="s2">&quot; &quot;</span><span class="p">)</span> <span class="k">if</span> <span class="ow">not</span> <span class="n">i</span> <span class="o">==</span> <span class="s1">&#39;&#39;</span><span class="p">]</span>
            <span class="k">if</span> <span class="nb">len</span><span class="p">(</span><span class="n">cleanline</span><span class="p">)</span> <span class="o">==</span> <span class="mi">5</span><span class="p">:</span>
                <span class="n">smalldict</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="n">smalldict</span><span class="p">[</span><span class="s2">&quot;element&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="n">cleanline</span><span class="p">[</span><span class="mi">1</span><span class="p">]</span>
                <span class="n">smalldict</span><span class="p">[</span><span class="s2">&quot;Mulliken GP&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="n">smalldict</span><span class="p">[</span><span class="s2">&quot;Loewdin GP&quot;</span><span class="p">]</span> <span class="o">=</span> <span class="p">{}</span>
                <span class="n">smalldict</span><span class="p">[</span><span class="s2">&quot;Mulliken GP&quot;</span><span class="p">][</span><span class="n">cleanline</span><span class="p">[</span><span class="mi">2</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">cleanline</span><span class="p">[</span><span class="mi">3</span><span class="p">])</span>
                <span class="n">smalldict</span><span class="p">[</span><span class="s2">&quot;Loewdin GP&quot;</span><span class="p">][</span><span class="n">cleanline</span><span class="p">[</span><span class="mi">2</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">cleanline</span><span class="p">[</span><span class="mi">4</span><span class="p">])</span>
            <span class="k">elif</span> <span class="nb">len</span><span class="p">(</span><span class="n">cleanline</span><span class="p">)</span> <span class="o">&gt;</span> <span class="mi">0</span><span class="p">:</span>
                <span class="n">smalldict</span><span class="p">[</span><span class="s2">&quot;Mulliken GP&quot;</span><span class="p">][</span><span class="n">cleanline</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">cleanline</span><span class="p">[</span><span class="mi">1</span><span class="p">])</span>
                <span class="n">smalldict</span><span class="p">[</span><span class="s2">&quot;Loewdin GP&quot;</span><span class="p">][</span><span class="n">cleanline</span><span class="p">[</span><span class="mi">0</span><span class="p">]]</span> <span class="o">=</span> <span class="nb">float</span><span class="p">(</span><span class="n">cleanline</span><span class="p">[</span><span class="mi">2</span><span class="p">])</span>
                <span class="k">if</span> <span class="s1">&#39;total&#39;</span> <span class="ow">in</span> <span class="n">cleanline</span><span class="p">[</span><span class="mi">0</span><span class="p">]:</span>
                    <span class="bp">self</span><span class="o">.</span><span class="n">list_dict_grosspop</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">smalldict</span><span class="p">)</span>

<div class="viewcode-block" id="Grosspop.get_structure_with_total_grosspop"><a class="viewcode-back" href="../../../../pymatgen.io.lobster.outputs.html#pymatgen.io.lobster.outputs.Grosspop.get_structure_with_total_grosspop">[docs]</a>    <span class="k">def</span> <span class="nf">get_structure_with_total_grosspop</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">structure_filename</span><span class="p">:</span> <span class="nb">str</span><span class="p">)</span> <span class="o">-&gt;</span> <span class="n">Structure</span><span class="p">:</span>
        <span class="sd">&quot;&quot;&quot;</span>
<span class="sd">        get a Structure with Mulliken and Loewdin total grosspopulations as site properties</span>
<span class="sd">        Args:</span>
<span class="sd">            structure_filename (str): filename of POSCAR</span>
<span class="sd">        Returns:</span>
<span class="sd">            Structure Object with Mulliken and Loewdin total grosspopulations as site properties</span>
<span class="sd">        &quot;&quot;&quot;</span>

        <span class="n">struct</span> <span class="o">=</span> <span class="n">Structure</span><span class="o">.</span><span class="n">from_file</span><span class="p">(</span><span class="n">structure_filename</span><span class="p">)</span>
        <span class="n">site_properties</span> <span class="o">=</span> <span class="p">{}</span>  <span class="c1"># type: Dict[str, Any]</span>
        <span class="n">mullikengp</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="n">loewdingp</span> <span class="o">=</span> <span class="p">[]</span>
        <span class="k">for</span> <span class="n">grosspop</span> <span class="ow">in</span> <span class="bp">self</span><span class="o">.</span><span class="n">list_dict_grosspop</span><span class="p">:</span>
            <span class="n">mullikengp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">grosspop</span><span class="p">[</span><span class="s2">&quot;Mulliken GP&quot;</span><span class="p">][</span><span class="s2">&quot;total&quot;</span><span class="p">])</span>
            <span class="n">loewdingp</span><span class="o">.</span><span class="n">append</span><span class="p">(</span><span class="n">grosspop</span><span class="p">[</span><span class="s2">&quot;Loewdin GP&quot;</span><span class="p">][</span><span class="s2">&quot;total&quot;</span><span class="p">])</span>

        <span class="n">site_properties</span> <span class="o">=</span> <span class="p">{</span><span class="s2">&quot;Total Mulliken GP&quot;</span><span class="p">:</span> <span class="n">mullikengp</span><span class="p">,</span> <span class="s2">&quot;Total Loewdin GP&quot;</span><span class="p">:</span> <span class="n">loewdingp</span><span class="p">}</span>
        <span class="n">new_struct</span> <span class="o">=</span> <span class="n">struct</span><span class="o">.</span><span class="n">copy</span><span class="p">(</span><span class="n">site_properties</span><span class="o">=</span><span class="n">site_properties</span><span class="p">)</span>
        <span class="k">return</span> <span class="n">new_struct</span></div></div>
</pre></div>

            <div class="clearer"></div>
          </div>
      </div>
      <div class="clearer"></div>
    </div>
    <div class="related" role="navigation" aria-label="related navigation">
      <h3>Navigation</h3>
      <ul>
        <li class="right" style="margin-right: 10px">
          <a href="../../../../genindex.html" title="General Index"
             >index</a></li>
        <li class="right" >
          <a href="../../../../py-modindex.html" title="Python Module Index"
             >modules</a> |</li>
        <li class="nav-item nav-item-0"><a href="../../../../index.html">pymatgen 2020.7.3 documentation</a> &#187;</li>
          <li class="nav-item nav-item-1"><a href="../../../index.html" >Module code</a> &#187;</li>
          <li class="nav-item nav-item-2"><a href="../../../pymatgen.html" >pymatgen</a> &#187;</li>
        <li class="nav-item nav-item-this"><a href="">pymatgen.io.lobster.outputs</a></li> 
      </ul>
    </div>

    <div class="footer" role="contentinfo">
        &#169; Copyright 2011, Pymatgen Development Team.
      Created using <a href="https://www.sphinx-doc.org/">Sphinx</a> 3.1.2.
    </div>
<div class="footer">This page uses <a href="http://analytics.google.com/">
Google Analytics</a> to collect statistics. You can disable it by blocking
the JavaScript coming from www.google-analytics.com.
<script type="text/javascript">
  (function() {
    var ga = document.createElement('script');
    ga.src = ('https:' == document.location.protocol ?
              'https://ssl' : 'http://www') + '.google-analytics.com/ga.js';
    ga.setAttribute('async', 'true');
    document.documentElement.firstChild.appendChild(ga);
  })();
</script>
</div>

  </body>
</html>